json-joy
Version:
Collection of libraries for building collaborative editing apps.
26 lines (25 loc) • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.text = void 0;
const json_crdt_extensions_1 = require("../../../json-crdt-extensions");
const text = (props, inline) => {
const style = (props.style || (props.style = {}));
const attrs = inline.attr();
let textDecoration = '';
let attr;
if (attrs[json_crdt_extensions_1.CommonSliceType.b])
style.fontWeight = 'bold';
if (attrs[json_crdt_extensions_1.CommonSliceType.i])
style.fontStyle = 'italic';
if (attrs[json_crdt_extensions_1.CommonSliceType.u])
textDecoration = 'underline';
if (attrs[json_crdt_extensions_1.CommonSliceType.overline])
textDecoration = textDecoration ? textDecoration + ' overline' : 'overline';
if (attrs[json_crdt_extensions_1.CommonSliceType.s])
textDecoration = textDecoration ? textDecoration + ' line-through' : 'line-through';
if ((attr = attrs[json_crdt_extensions_1.CommonSliceType.col]))
style.color = attr[0].slice.data() + '';
style.textDecoration = textDecoration;
return props;
};
exports.text = text;