mirror of
https://github.com/codex-team/editor.js
synced 2024-06-05 07:22:26 +02:00
Update code block release.1.5.5 (#176)
This commit is contained in:
parent
c8808e802b
commit
d581856d78
|
@ -1,5 +1,7 @@
|
||||||
.ce-code {
|
.ce-code {
|
||||||
display: block;
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100px;
|
||||||
border: 1px solid #ebeef3;
|
border: 1px solid #ebeef3;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
background: #fdfdff !important;
|
background: #fdfdff !important;
|
||||||
|
@ -13,6 +15,9 @@
|
||||||
line-height: 1.5em;
|
line-height: 1.5em;
|
||||||
color: #325179;
|
color: #325179;
|
||||||
font-size: .8em;
|
font-size: .8em;
|
||||||
|
|
||||||
|
resize: vertical;
|
||||||
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,17 +14,32 @@ var code = (function(code_plugin) {
|
||||||
*/
|
*/
|
||||||
var make_ = function (data) {
|
var make_ = function (data) {
|
||||||
|
|
||||||
var tag = codex.editor.draw.node('CODE', [baseClass], {});
|
var tag = codex.editor.draw.node('TEXTAREA', [baseClass], {});
|
||||||
|
|
||||||
if (data && data.text) {
|
if (data && data.text) {
|
||||||
tag.innerHTML = data.text;
|
tag.value = data.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.contentEditable = true;
|
|
||||||
|
|
||||||
return tag;
|
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
|
* Method to render HTML block from JSON
|
||||||
*/
|
*/
|
||||||
|
@ -38,9 +53,12 @@ var code = (function(code_plugin) {
|
||||||
*/
|
*/
|
||||||
code_plugin.save = function (blockContent) {
|
code_plugin.save = function (blockContent) {
|
||||||
|
|
||||||
var data = {
|
var escaped = escapeHTML_(blockContent.value),
|
||||||
text : blockContent.innerHTML
|
data = {
|
||||||
};
|
text : escaped
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue