You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Global-sales/src/components/RoosterEditor/editorOptions/codes/DefaultFormatCode.ts

32 lines
1.1 KiB
TypeScript

import { CodeElement } from './CodeElement';
import { ContentModelSegmentFormat } from 'roosterjs-content-model-types';
export class DefaultFormatCode extends CodeElement {
constructor(private defaultFormat: ContentModelSegmentFormat) {
super();
}
getCode() {
let {
fontWeight,
italic,
underline,
fontFamily,
fontSize,
textColor,
backgroundColor,
} = this.defaultFormat;
let lines = [
fontWeight ? `fontWeight: '${fontWeight}',\n` : null,
italic ? 'italic: true,\n' : null,
underline ? 'underline: true,\n' : null,
fontFamily ? `fontFamily: '${this.encode(fontFamily)}',\n` : null,
fontSize ? `fontSize: '${this.encode(fontSize)}',\n` : null,
textColor ? `textColor: '${this.encode(textColor)}',\n` : null,
backgroundColor ? `backgroundColor: '${this.encode(backgroundColor)}',\n` : null,
].filter(line => !!line);
return lines.length > 0 ? '{\n' + this.indent(lines.join('')) + '}' : '';
}
}