UNPKG

devexpress-richedit

Version:

DevExpress Rich Text Editor is an advanced word-processing tool designed for working with rich text documents.

77 lines (76 loc) 4.8 kB
import { CharacterProperties } from '../../../../model/character/character-properties'; import { CharacterFormattingScript, CharacterPropertiesMask, StrikeoutType, UnderlineType } from '../../../../model/character/enums'; import { Log } from '../../logger/base-logger/log'; import { Pair } from '@devexpress/utils/lib/class/pair'; import { BaseFormatter, StdProps } from '../base-formatter'; export class CCF_CharacterProperties extends BaseFormatter { isHandleObject(obj) { return obj instanceof CharacterProperties; } getShortDescription(_config) { const useVal = this.getUseVal(); const list = []; if (useVal & CharacterPropertiesMask.UseHidden) list.push(new Pair("", this.curr.hidden ? "hidden" : "")); if (useVal & CharacterPropertiesMask.UseFontName) list.push(new Pair("f", this.curr.fontInfo)); if (useVal & CharacterPropertiesMask.UseDoubleFontSize) list.push(new Pair("fSize", this.curr.fontSize)); if (useVal & CharacterPropertiesMask.UseShadingInfoIndex) list.push(new Pair("bckColor", BaseFormatter.getColorBoxNode(CharacterProperties.getActualBackgroundColor(this.curr, this.model.colorProvider)))); if (this.isMasked()) list.push(new Pair("mask", Log.mask(CharacterPropertiesMask, useVal, CharacterPropertiesMask.UseNone))); return this.stdShow(new StdProps(list).showAsLine()); } availableFullDescription(_config) { return true; } getFullDescription(_config) { const list = []; const useVal = this.getUseVal(); if (this.isMasked()) list.push(new Pair("mask", Log.mask(CharacterPropertiesMask, useVal, CharacterPropertiesMask.UseNone))); if (useVal & CharacterPropertiesMask.UseHidden) list.push(new Pair("hidden", this.curr.hidden)); if (useVal & CharacterPropertiesMask.UseFontName) list.push(new Pair("fontInfo", this.curr.fontInfo)); if (useVal & CharacterPropertiesMask.UseDoubleFontSize) list.push(new Pair("fontSize", this.curr.fontSize)); if (useVal & CharacterPropertiesMask.UseFontBold) list.push(new Pair("fontBold", this.curr.fontBold)); if (useVal & CharacterPropertiesMask.UseFontItalic) list.push(new Pair("fontItalic", this.curr.fontItalic)); if (useVal & CharacterPropertiesMask.UseForeColorIndex) list.push(new Pair("textColor", BaseFormatter.getColorBoxNode(this.curr.textColor.toRgb(this.model.colorProvider)))); if (useVal & CharacterPropertiesMask.UseShadingInfoIndex) list.push(new Pair("backColor", BaseFormatter.getColorBoxNode(CharacterProperties.getActualBackgroundColor(this.curr, this.model.colorProvider)))); if (useVal & CharacterPropertiesMask.UseAllCaps) list.push(new Pair("allCaps", this.curr.allCaps)); if (useVal & CharacterPropertiesMask.UseSmallCaps) list.push(new Pair("smallCaps", this.curr.smallCaps)); if (useVal & CharacterPropertiesMask.UseFontStrikeoutType) list.push(new Pair("fontStrikeoutType", StrikeoutType[this.curr.fontStrikeoutType])); if (useVal & CharacterPropertiesMask.UseFontUnderlineType) list.push(new Pair("fontUnderlineType", UnderlineType[this.curr.fontUnderlineType])); if (useVal & CharacterPropertiesMask.UseNoProof) list.push(new Pair("noProof", this.curr.noProof)); if (useVal & CharacterPropertiesMask.UseScript) list.push(new Pair("script", CharacterFormattingScript[this.curr.script])); if (useVal & CharacterPropertiesMask.UseStrikeoutColorIndex) list.push(new Pair("strikeoutColor", BaseFormatter.getColorBoxNode(this.curr.strikeoutColor.toRgb(this.model.colorProvider)))); if (useVal & CharacterPropertiesMask.UseStrikeoutWordsOnly) list.push(new Pair("strikeoutWordsOnly", this.curr.strikeoutWordsOnly)); if (useVal & CharacterPropertiesMask.UseUnderlineColorIndex) list.push(new Pair("underlineColor", BaseFormatter.getColorBoxNode(this.curr.underlineColor.toRgb(this.model.colorProvider)))); if (useVal & CharacterPropertiesMask.UseUnderlineWordsOnly) list.push(new Pair("underlineWordsOnly", this.curr.underlineWordsOnly)); return this.stdShow(new StdProps(list).showAsColumn()); } getUseVal() { return this.isMasked() ? this.curr.getUseValueFull() : CharacterPropertiesMask.UseAll; } isMasked() { return this.curr.useValue !== undefined; } } CCF_CharacterProperties._foo = BaseFormatter.addToFormattersList(new CCF_CharacterProperties());