New project structure (#214)

This commit is contained in:
Peter Savchenko 2017-11-25 12:14:06 +03:00 committed by GitHub
commit ed28a85db6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 0 additions and 800 deletions

View file

@ -0,0 +1,30 @@
.ce-code {
display: block;
width: 100%;
min-height: 100px;
border: 1px solid #ebeef3;
border-radius: 3px;
background: #fdfdff !important;
margin: 1em 0 !important;
padding: .5em .8em;
box-sizing: border-box;
white-space: pre-wrap;
font-family: 'monospace', 'monaco', 'consolas', 'courier';
line-height: 1.5em;
color: #325179;
font-size: .8em;
resize: vertical;
outline: none;
}
/**
* CodeX Editor styles overlay
* @todo change for ce-tool-wrapper__code
*/
.ce_block[data-type="code"]{
padding: 1em 0 !important;
}

View file

@ -0,0 +1,82 @@
/**
* Code Plugin\
* Creates code tag and adds content to this tag
*/
var code = (function(code_plugin) {
var baseClass = "ce-code";
/**
* Make initial header block
* @param {object} JSON with block data
* @return {Element} element to append
*/
var make_ = function (data) {
var tag = codex.editor.draw.node('TEXTAREA', [baseClass], {});
if (data && data.text) {
tag.value = data.text;
}
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
*/
code_plugin.render = function (data) {
return make_(data);
};
/**
* Method to extract JSON data from HTML block
*/
code_plugin.save = function (blockContent) {
var escaped = escapeHTML_(blockContent.value),
data = {
text : escaped
};
return data;
};
code_plugin.validate = function (data) {
if (data.text.trim() == '')
return;
return true;
};
code_plugin.destroy = function () {
code = null;
};
return code_plugin;
})({});