Files
docx-js/src/file/styles/style/character-style.ts

43 lines
1.2 KiB
TypeScript
Raw Normal View History

import { IRunStylePropertiesOptions, RunProperties } from "file/paragraph/run/properties";
2019-10-04 01:20:41 +01:00
2018-11-13 11:04:29 -02:00
import { BasedOn, Link, SemiHidden, UiPriority, UnhideWhenUsed } from "./components";
import { Style } from "./style";
2019-10-04 01:20:41 +01:00
export interface IBaseCharacterStyleOptions {
readonly basedOn?: string;
readonly link?: string;
readonly semiHidden?: boolean;
readonly run?: IRunStylePropertiesOptions;
2019-10-04 01:20:41 +01:00
}
export interface ICharacterStyleOptions extends IBaseCharacterStyleOptions {
readonly id: string;
readonly name?: string;
}
export class CharacterStyle extends Style {
private readonly runProperties: RunProperties;
2019-10-04 01:20:41 +01:00
constructor(options: ICharacterStyleOptions) {
super({ type: "character", styleId: options.id }, options.name);
this.runProperties = new RunProperties(options.run);
this.root.push(this.runProperties);
2019-10-04 01:20:41 +01:00
this.root.push(new UiPriority(99));
this.root.push(new UnhideWhenUsed());
2019-10-04 01:20:41 +01:00
if (options.basedOn) {
this.root.push(new BasedOn(options.basedOn));
}
2019-10-04 01:20:41 +01:00
if (options.link) {
this.root.push(new Link(options.link));
}
2019-10-04 01:20:41 +01:00
if (options.semiHidden) {
this.root.push(new SemiHidden());
}
2019-08-05 13:42:45 +03:00
}
}