new modifications

1) improved blocks transmition. We can switch contenteditable elements
by clicking arrow buttons.

2) Refactoring (Removing) blocks. When backspace key pressed and input
is empty, we can remove from DOM this element
This commit is contained in:
khaydarov 2016-07-13 20:08:53 +03:00
commit 9425e17598
19 changed files with 408 additions and 403 deletions

7
plugins/code/code.css Normal file
View file

@ -0,0 +1,7 @@
.tool-code {
display: block;
font-family: 'monospace', 'monaco', 'consolas', 'courier';
line-height: 1.5em;
background: #f8f8fd !important;
color: #4a8bd1;
}

70
plugins/code/code.js Normal file
View file

@ -0,0 +1,70 @@
/**
* Code Plugin\
* Creates code tag and adds content to this tag
*/
var codeTool = {
baseClass : "tool-code",
/**
* Make initial header block
* @param {object} JSON with block data
* @return {Element} element to append
*/
make : function (data) {
var tag = document.createElement('code');
tag.classList += codeTool.baseClass;
if (data && data.text) {
tag.innerHTML = data.text;
}
tag.contentEditable = true;
return tag;
},
/**
* Method to render HTML block from JSON
*/
render : function (data) {
return codeTool.make(data);
},
/**
* Method to extract JSON data from HTML block
*/
save : function (block){
var data = {
text : null
};
data.text = blockData.textContent;
return data;
},
};
/**
* Now plugin is ready.
* Add it to redactor tools
*/
cEditor.tools.code = {
type : 'code',
iconClassname : 'ce-icon-code',
make : codeTool.make,
appendCallback : null,
settings : null,
render : codeTool.render,
save : codeTool.save
};