2018-03-13 21:39:27 +01:00
|
|
|
import styles from './styles.scss';
|
|
|
|
|
/**
|
|
|
|
|
* Override the editor css
|
|
|
|
|
* @param {[type]} block [description]
|
|
|
|
|
* @return {[type]} [description]
|
|
|
|
|
*/
|
|
|
|
|
|
2018-03-13 13:12:06 +01:00
|
|
|
export function getBlockStyle(block) {
|
|
|
|
|
switch (block.getType()) {
|
|
|
|
|
case 'blockquote':
|
|
|
|
|
return styles.editorBlockquote;
|
|
|
|
|
case 'code-block':
|
|
|
|
|
return styles.editorCodeBlock;
|
|
|
|
|
default: return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function getInnerText(style) {
|
|
|
|
|
let innerText;
|
|
|
|
|
|
|
|
|
|
switch (style) {
|
|
|
|
|
case 'BOLD':
|
2018-03-15 20:21:21 +01:00
|
|
|
innerText = '**bold text**';
|
2018-03-13 13:12:06 +01:00
|
|
|
break;
|
|
|
|
|
case 'ITALIC':
|
2018-03-15 20:21:21 +01:00
|
|
|
innerText = '*italic text*';
|
2018-03-13 13:12:06 +01:00
|
|
|
break;
|
|
|
|
|
case 'UNDERLINE':
|
2018-03-15 20:21:21 +01:00
|
|
|
innerText = '__underlined text__';
|
2018-03-13 13:12:06 +01:00
|
|
|
break;
|
|
|
|
|
case 'LINK':
|
|
|
|
|
innerText = '[text](link)';
|
|
|
|
|
break;
|
2018-03-20 12:12:02 +01:00
|
|
|
case 'STRIKED':
|
|
|
|
|
innerText = '~~striked out~~';
|
|
|
|
|
break;
|
2018-03-13 13:12:06 +01:00
|
|
|
default:
|
|
|
|
|
innerText = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return innerText;
|
|
|
|
|
}
|
2018-03-13 21:39:27 +01:00
|
|
|
|
2018-03-20 15:17:33 +01:00
|
|
|
export function getBlockContent(style) {
|
|
|
|
|
switch (style) {
|
|
|
|
|
case 'IMG':
|
|
|
|
|
return {
|
|
|
|
|
innerContent: 'link',
|
|
|
|
|
endReplacer: ')',
|
|
|
|
|
startReplacer: ' {
|
|
|
|
|
return {
|
|
|
|
|
end: selection.getEndOffset(),
|
|
|
|
|
start: selection.getStartOffset(),
|
|
|
|
|
};
|
|
|
|
|
}
|