update file/styles

This commit is contained in:
Tom Hunkapiller
2021-05-25 04:27:10 +03:00
parent 63cea76eac
commit b05748da25
9 changed files with 252 additions and 299 deletions

View File

@ -1,12 +1,8 @@
import { IRunStylePropertiesOptions, RunProperties } from "file/paragraph/run/properties";
import { BasedOn, Link, SemiHidden, UiPriority, UnhideWhenUsed } from "./components";
import { Style } from "./style";
import { IStyleOptions, Style } from "./style";
export interface IBaseCharacterStyleOptions {
readonly basedOn?: string;
readonly link?: string;
readonly semiHidden?: boolean;
export interface IBaseCharacterStyleOptions extends IStyleOptions {
readonly run?: IRunStylePropertiesOptions;
}
@ -19,24 +15,16 @@ export class StyleForCharacter extends Style {
private readonly runProperties: RunProperties;
constructor(options: ICharacterStyleOptions) {
super({ type: "character", styleId: options.id }, options.name);
super(
{ type: "character", styleId: options.id },
{
uiPriority: 99,
unhideWhenUsed: true,
...options,
},
);
this.runProperties = new RunProperties(options.run);
this.root.push(this.runProperties);
this.root.push(new UiPriority(99));
this.root.push(new UnhideWhenUsed());
if (options.basedOn) {
this.root.push(new BasedOn(options.basedOn));
}
if (options.link) {
this.root.push(new Link(options.link));
}
if (options.semiHidden) {
this.root.push(new SemiHidden());
}
}
}