mirror of
https://github.com/codex-team/editor.js
synced 2026-03-15 23:25:47 +01:00
Update code block release.1.5.5 (#176)
This commit is contained in:
parent
c8808e802b
commit
d581856d78
2 changed files with 30 additions and 7 deletions
|
|
@ -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;
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue