strapi-plugin-content-manager
Version:
A powerful UI to easily manage your data.
117 lines (109 loc) • 2.42 kB
JavaScript
import { trimEnd, trimStart } from 'lodash';
/**
* Override the editor css
* @param {[type]} block [description]
* @return {[type]} [description]
*/
export function getBlockStyle() {
return null;
}
export function getBlockContent(style) {
switch (style) {
case 'IMG':
return {
innerContent: 'link',
endReplacer: ')',
startReplacer: ' => ({
anchorOffset: initPosition + content.length - trimStart(content, startReplacer).length,
focusOffset: initPosition + trimEnd(content, endReplacer).length,
});
/**
* Get the start and end offset
* @param {Object} selection
* @return {Object}
*/
export function getOffSets(selection) {
return {
end: selection.getEndOffset(),
start: selection.getStartOffset(),
};
}
export function getKeyCommandData(command) {
let content;
let style;
switch (command) {
case 'bold':
content = '**textToReplace**';
style = 'BOLD';
break;
case 'italic':
content = '*textToReplace*';
style = 'ITALIC';
break;
case 'underline':
content = '<u>textToReplace</u>';
style = 'UNDERLINE';
break;
default:
content = '';
style = '';
}
return { content, style };
}