UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

22 lines (21 loc) 859 B
import { CommonSliceType } from '../../../json-crdt-extensions'; export const text = (props, inline) => { const style = (props.style || (props.style = {})); const attrs = inline.attr(); let textDecoration = ''; let attr; if (attrs[CommonSliceType.b]) style.fontWeight = 'bold'; if (attrs[CommonSliceType.i]) style.fontStyle = 'italic'; if (attrs[CommonSliceType.u]) textDecoration = 'underline'; if (attrs[CommonSliceType.overline]) textDecoration = textDecoration ? textDecoration + ' overline' : 'overline'; if (attrs[CommonSliceType.s]) textDecoration = textDecoration ? textDecoration + ' line-through' : 'line-through'; if ((attr = attrs[CommonSliceType.col])) style.color = attr[0].slice.data() + ''; style.textDecoration = textDecoration; return props; };