54 lines
1.0 KiB
JavaScript
Raw Normal View History

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;
}
}
2018-03-13 21:39:27 +01:00
// TODO: this could be improved
2018-03-13 13:12:06 +01:00
export function getInnerText(style) {
let innerText;
switch (style) {
case 'BOLD':
innerText = '**text in bold**';
break;
case 'ITALIC':
innerText = '*text in italic*';
break;
case 'UNDERLINE':
2018-03-14 15:12:06 +01:00
innerText = '__text underlined__';
2018-03-13 13:12:06 +01:00
break;
case 'LINK':
innerText = '[text](link)';
break;
default:
innerText = '';
}
return innerText;
}
2018-03-13 21:39:27 +01:00
/**
* Get the start and end offset
* @param {Object} selection
* @return {Object}
*/
export function getOffSets(selection) {
return {
end: selection.getEndOffset(),
start: selection.getStartOffset(),
};
}