mirror of
https://github.com/codex-team/editor.js
synced 2026-03-16 07:35:48 +01:00
update structure
This commit is contained in:
parent
8ef08e47c0
commit
5e462d4f7f
1 changed files with 13 additions and 121 deletions
|
|
@ -3,23 +3,28 @@
|
|||
* Creates DIV tag and adds content to this tag
|
||||
*/
|
||||
|
||||
|
||||
class Paragraph {
|
||||
|
||||
constructor(data) {
|
||||
static get name() {
|
||||
|
||||
this.CLASS = 'ce-paragraph';
|
||||
|
||||
this.element = this.render(data);
|
||||
return 'paragraph';
|
||||
|
||||
}
|
||||
|
||||
render(data) {
|
||||
constructor(data={}) {
|
||||
|
||||
this.CLASS = 'ce-paragraph';
|
||||
|
||||
this.element = this.render();
|
||||
this.data = data;
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
let div = document.createElement('DIV');
|
||||
|
||||
div.classList.add(this.CLASS);
|
||||
div.innerHTML = data.text || '';
|
||||
div.contentEditable = true;
|
||||
|
||||
return div;
|
||||
|
|
@ -50,127 +55,14 @@ class Paragraph {
|
|||
|
||||
return {
|
||||
'text': text,
|
||||
'format': 'html',
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
static get name() {
|
||||
set data(data) {
|
||||
|
||||
return 'paragraph';
|
||||
this.element.innerHTML = data.text || '';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// var paragraph = (function(paragraph_plugin) {
|
||||
//
|
||||
// /**
|
||||
// * @private
|
||||
// *
|
||||
// * Make initial paragraph block
|
||||
// * @param {object} JSON with block data
|
||||
// * @return {Element} element to append
|
||||
// */
|
||||
//
|
||||
// var make_ = function (data) {
|
||||
//
|
||||
// /** Create Empty DIV */
|
||||
// var tag = codex.editor.draw.node('DIV', ['ce-paragraph'], {});
|
||||
//
|
||||
// if (data && data.text) {
|
||||
// tag.innerHTML = data.text;
|
||||
// }
|
||||
//
|
||||
// tag.contentEditable = true;
|
||||
//
|
||||
// return tag;
|
||||
//
|
||||
// };
|
||||
//
|
||||
// /**
|
||||
// * @private
|
||||
// *
|
||||
// * Handles input data for save
|
||||
// * @param data
|
||||
// */
|
||||
// var prepareDataForSave_ = function(data) {
|
||||
//
|
||||
// };
|
||||
//
|
||||
// /**
|
||||
// * @public
|
||||
// *
|
||||
// * Plugins should have prepare method
|
||||
// * @param config
|
||||
// */
|
||||
// paragraph_plugin.prepare = function(config) {
|
||||
//
|
||||
// };
|
||||
//
|
||||
// /*
|
||||
// * @public
|
||||
// *
|
||||
// * Method to render HTML block from JSON
|
||||
// */
|
||||
// paragraph_plugin.render = function (data) {
|
||||
//
|
||||
// return make_(data);
|
||||
//
|
||||
// };
|
||||
//
|
||||
// /**
|
||||
// * @public
|
||||
// *
|
||||
// * Check output data for validity.
|
||||
// * Should be defined by developer
|
||||
// */
|
||||
// paragraph_plugin.validate = function(output) {
|
||||
//
|
||||
// if (output.text === '')
|
||||
// return;
|
||||
//
|
||||
// return output;
|
||||
// };
|
||||
//
|
||||
// /**
|
||||
// * @public
|
||||
// *
|
||||
// * Method to extract JSON data from HTML block
|
||||
// */
|
||||
// paragraph_plugin.save = function (blockContent){
|
||||
//
|
||||
// var wrappedText = codex.editor.content.wrapTextWithParagraphs(blockContent.innerHTML),
|
||||
// sanitizerConfig = {
|
||||
// tags : {
|
||||
// p : {},
|
||||
// a: {
|
||||
// href: true,
|
||||
// target: '_blank',
|
||||
// rel: 'nofollow'
|
||||
// },
|
||||
// i: {},
|
||||
// b: {},
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// var data = {
|
||||
// "text": codex.editor.sanitizer.clean(wrappedText, sanitizerConfig),
|
||||
// "format": "html",
|
||||
// "introText": '<<same>>'
|
||||
// };
|
||||
//
|
||||
// return data;
|
||||
//
|
||||
// };
|
||||
//
|
||||
// paragraph_plugin.destroy = function () {
|
||||
//
|
||||
// paragraph = null;
|
||||
//
|
||||
// };
|
||||
//
|
||||
// return paragraph_plugin;
|
||||
//
|
||||
// })({});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue