mirror of
https://github.com/codex-team/editor.js
synced 2024-06-29 02:40:23 +02:00
quotes#1
This commit is contained in:
parent
53a23f02a9
commit
78d3bdf28c
|
@ -2065,17 +2065,10 @@ cEditor.tools.header = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/
|
|
||||||
/** QUOTE PLUGIN **/
|
/** QUOTE PLUGIN **/
|
||||||
|
|
||||||
var quoteTools = {
|
var quoteTools = {
|
||||||
|
|
||||||
quote : null,
|
|
||||||
style : null,
|
|
||||||
author : null,
|
|
||||||
position : null,
|
|
||||||
photo : null,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make Quote from JSON datasets
|
* Make Quote from JSON datasets
|
||||||
*/
|
*/
|
||||||
|
@ -2085,12 +2078,6 @@ var quoteTools = {
|
||||||
|
|
||||||
if (data && data.type) {
|
if (data && data.type) {
|
||||||
|
|
||||||
this.quote = data.text;
|
|
||||||
this.style = data.type;
|
|
||||||
this.author = data.author || null;
|
|
||||||
this.position = data.position || null;
|
|
||||||
this.photo = data.photo || null;
|
|
||||||
|
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 'simple':
|
case 'simple':
|
||||||
tag = quoteTools.makeSimpleQuote(data);
|
tag = quoteTools.makeSimpleQuote(data);
|
||||||
|
@ -2105,12 +2092,11 @@ var quoteTools = {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
tag = document.createElement('BLOCKQUOTE');
|
tag = document.createElement('BLOCKQUOTE');
|
||||||
tag.contentEditable = 'true';
|
|
||||||
|
|
||||||
this.style = 'simple';
|
tag.contentEditable = 'true';
|
||||||
|
tag.id = 'ce_quote--text';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2166,7 +2152,8 @@ var quoteTools = {
|
||||||
|
|
||||||
selectTypeButton.className = 'ce_plugin_quote--select_button';
|
selectTypeButton.className = 'ce_plugin_quote--select_button';
|
||||||
|
|
||||||
this.addSelectTypeClickListener(selectTypeButton, type);
|
var quoteStyle = quoteTools.selectTypeQuoteStyle(type);
|
||||||
|
quoteTools.addSelectTypeClickListener(selectTypeButton, quoteStyle);
|
||||||
|
|
||||||
holder.appendChild(selectTypeButton);
|
holder.appendChild(selectTypeButton);
|
||||||
|
|
||||||
|
@ -2176,9 +2163,7 @@ var quoteTools = {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
addSelectTypeClickListener : function(el, type) {
|
selectTypeQuoteStyle : function(type) {
|
||||||
|
|
||||||
var quoteStyleFunction;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Choose Quote style to replace
|
* Choose Quote style to replace
|
||||||
|
@ -2195,13 +2180,19 @@ var quoteTools = {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return quoteStyleFunction;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
addSelectTypeClickListener : function(el, quoteStyle) {
|
||||||
|
|
||||||
el.addEventListener('click', function () {
|
el.addEventListener('click', function () {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parsing currentNode to JSON.
|
* Parsing currentNode to JSON.
|
||||||
*/
|
*/
|
||||||
var parsedOldQuote = quoteTools.parseBlockQuote(),
|
var parsedOldQuote = quoteTools.parseBlockQuote(),
|
||||||
newStyledQuote = quoteStyleFunction(parsedOldQuote);
|
newStyledQuote = quoteStyle(parsedOldQuote);
|
||||||
|
|
||||||
cEditor.content.replaceBlock(cEditor.content.currentNode, newStyledQuote, 'quote');
|
cEditor.content.replaceBlock(cEditor.content.currentNode, newStyledQuote, 'quote');
|
||||||
|
|
||||||
|
@ -2215,7 +2206,7 @@ var quoteTools = {
|
||||||
|
|
||||||
var blockquote = document.createElement('BLOCKQUOTE');
|
var blockquote = document.createElement('BLOCKQUOTE');
|
||||||
|
|
||||||
blockquote.innerHTML = data.text;
|
blockquote.innerHTML = data.text || '';
|
||||||
|
|
||||||
blockquote.classList.add('quoteStyle-simple--blockquote');
|
blockquote.classList.add('quoteStyle-simple--blockquote');
|
||||||
|
|
||||||
|
@ -2233,7 +2224,6 @@ var quoteTools = {
|
||||||
quote = document.createElement('DIV'),
|
quote = document.createElement('DIV'),
|
||||||
author = document.createElement('DIV');
|
author = document.createElement('DIV');
|
||||||
|
|
||||||
|
|
||||||
/* Creating ContentEditable block for quote */
|
/* Creating ContentEditable block for quote */
|
||||||
quote.contentEditable = 'true';
|
quote.contentEditable = 'true';
|
||||||
|
|
||||||
|
@ -2309,29 +2299,29 @@ var quoteTools = {
|
||||||
|
|
||||||
var currentNode = block || cEditor.content.currentNode,
|
var currentNode = block || cEditor.content.currentNode,
|
||||||
photo = currentNode.getElementsByTagName('img')[0],
|
photo = currentNode.getElementsByTagName('img')[0],
|
||||||
quote = document.getElementById('ce_quote--text'),
|
quote = currentNode.querySelector('#ce_quote--text'),
|
||||||
author = document.getElementById('ce_quote--author'),
|
author = currentNode.querySelector('#ce_quote--author'),
|
||||||
position = document.getElementById('ce_quote--position');
|
position = currentNode.querySelector('#ce_quote--position');
|
||||||
|
|
||||||
this.style = currentNode.dataset.quoteStyle;
|
|
||||||
|
|
||||||
|
// this.style = currentNode.dataset.quoteStyle;
|
||||||
|
console.log(currentNode);
|
||||||
if ( position )
|
if ( position )
|
||||||
this.position = position.textContent;
|
position = position.textContent;
|
||||||
|
|
||||||
if ( author )
|
if ( author )
|
||||||
this.author = author.textContent;
|
author = author.textContent;
|
||||||
|
|
||||||
if ( quote )
|
if ( quote )
|
||||||
this.quote = quote.textContent;
|
quote = quote.textContent;
|
||||||
|
|
||||||
if ( photo )
|
if ( photo )
|
||||||
this.photo = photo.src;
|
photo = photo.src;
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
text : this.quote,
|
text : quote,
|
||||||
author : this.author,
|
author : author,
|
||||||
position : this.position,
|
position : position,
|
||||||
photo : this.photo,
|
photo : photo,
|
||||||
};
|
};
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
|
@ -281,7 +281,6 @@
|
||||||
.quoteStyle-withPhoto--quote {
|
.quoteStyle-withPhoto--quote {
|
||||||
outline: none;
|
outline: none;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-align: justify;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.quoteStle-withPhoto--author::before {
|
.quoteStle-withPhoto--author::before {
|
||||||
|
|
|
@ -126,7 +126,7 @@
|
||||||
type : 'simple',
|
type : 'simple',
|
||||||
text : 'git — распределенная система контроля версий файлов.<br> «Распределенная» значит, что каждый репозиторий содержит всю историю изменений, и из него можно развернуть полноценную рабочую копию проекта.',
|
text : 'git — распределенная система контроля версий файлов.<br> «Распределенная» значит, что каждый репозиторий содержит всю историю изменений, и из него можно развернуть полноценную рабочую копию проекта.',
|
||||||
photo : '',
|
photo : '',
|
||||||
author : 'sss',
|
author : '',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
BIN
img/01.jpg
Executable file
BIN
img/01.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
Loading…
Reference in a new issue