mirror of
https://github.com/codex-team/editor.js
synced 2024-05-23 08:42:25 +02:00
parent
dae94e11e3
commit
326767a202
|
@ -6,7 +6,8 @@
|
|||
padding: 0.7em 0 !important;
|
||||
line-height: 1.7em;
|
||||
}
|
||||
.ce-paragraph:empty::before{
|
||||
.ce-paragraph:empty::before,
|
||||
.ce-paragraph p:empty::before{
|
||||
content : attr(data-placeholder);
|
||||
color: #818BA1;
|
||||
opacity: .7;
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
/**
|
||||
* Paragraph Plugin
|
||||
* Creates P tag and adds content to this tag
|
||||
* Creates DIV tag and adds content to this tag
|
||||
*/
|
||||
|
||||
var paragraph = (function(paragraph) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* Make initial header block
|
||||
* @param {object} JSON with block data
|
||||
* @return {Element} element to append
|
||||
*/
|
||||
paragraph.make = function (data) {
|
||||
|
||||
var make_ = function (data) {
|
||||
|
||||
/** Create Empty DIV */
|
||||
var tag = codex.draw.node('DIV', ['ce-paragraph'], {});
|
||||
|
@ -21,11 +24,6 @@ var paragraph = (function(paragraph) {
|
|||
|
||||
tag.contentEditable = true;
|
||||
|
||||
/**
|
||||
* if plugin need to add placeholder
|
||||
* tag.setAttribute('data-placeholder', 'placehoder');
|
||||
*/
|
||||
|
||||
/**
|
||||
* @uses Paste tool callback.
|
||||
* Function analyzes pasted data
|
||||
|
@ -39,52 +37,67 @@ var paragraph = (function(paragraph) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Method to render HTML block from JSON
|
||||
* @private
|
||||
*
|
||||
* Handles input data for save
|
||||
* @param data
|
||||
*/
|
||||
paragraph.render = function (data) {
|
||||
|
||||
return this.make(data);
|
||||
var prepareDataForSave_ = function(data) {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*
|
||||
* Plugins should have prepare method
|
||||
* @param config
|
||||
*/
|
||||
paragraph.prepare = function(config) {
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* @public
|
||||
*
|
||||
* Method to render HTML block from JSON
|
||||
*/
|
||||
paragraph.render = function (data) {
|
||||
|
||||
return make_(data);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*
|
||||
* Check output data for validity.
|
||||
* Should be defined by developer
|
||||
*/
|
||||
paragraph.validate = function(output) {
|
||||
|
||||
if (output.text == '')
|
||||
return;
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
/**
|
||||
* @public
|
||||
*
|
||||
* Method to extract JSON data from HTML block
|
||||
*/
|
||||
paragraph.save = function (blockContent){
|
||||
|
||||
var data = {
|
||||
text : null,
|
||||
format: "html",
|
||||
introText: '<<same>>'
|
||||
"text": blockContent.innerHTML,
|
||||
"format": "html",
|
||||
"introText": '<<same>>'
|
||||
};
|
||||
|
||||
data.text = blockContent.innerHTML;
|
||||
|
||||
return data;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Validate data.
|
||||
* Define which objects are important and which are not
|
||||
*
|
||||
* @param data
|
||||
*
|
||||
* @return [Boolean]
|
||||
*/
|
||||
paragraph.validate = function(data) {
|
||||
|
||||
/**
|
||||
* Do not allow:
|
||||
* - Empty text
|
||||
*/
|
||||
if (data.text.trim() == '')
|
||||
return;
|
||||
|
||||
return true;
|
||||
|
||||
};
|
||||
|
||||
return paragraph;
|
||||
|
||||
})({});
|
||||
|
|
Loading…
Reference in a new issue