2020-07-11 17:01:32 +08:00
|
|
|
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";
|
2018-11-13 11:04:03 -02:00
|
|
|
import { Style } from "./style";
|
|
|
|
|
2019-10-04 01:20:41 +01:00
|
|
|
export interface IBaseCharacterStyleOptions {
|
|
|
|
readonly basedOn?: string;
|
|
|
|
readonly link?: string;
|
|
|
|
readonly semiHidden?: boolean;
|
2020-07-11 17:01:32 +08:00
|
|
|
readonly run?: IRunStylePropertiesOptions;
|
2019-10-04 01:20:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ICharacterStyleOptions extends IBaseCharacterStyleOptions {
|
|
|
|
readonly id: string;
|
|
|
|
readonly name?: string;
|
|
|
|
}
|
|
|
|
|
2018-11-13 11:04:03 -02:00
|
|
|
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);
|
2020-07-11 17:01:32 +08:00
|
|
|
|
|
|
|
this.runProperties = new RunProperties(options.run);
|
|
|
|
|
2018-11-13 11:04:03 -02:00
|
|
|
this.root.push(this.runProperties);
|
2019-10-04 01:20:41 +01:00
|
|
|
this.root.push(new UiPriority(99));
|
2018-11-13 11:04:03 -02:00
|
|
|
this.root.push(new UnhideWhenUsed());
|
|
|
|
|
2019-10-04 01:20:41 +01:00
|
|
|
if (options.basedOn) {
|
|
|
|
this.root.push(new BasedOn(options.basedOn));
|
|
|
|
}
|
2018-11-13 11:04:03 -02:00
|
|
|
|
2019-10-04 01:20:41 +01:00
|
|
|
if (options.link) {
|
|
|
|
this.root.push(new Link(options.link));
|
|
|
|
}
|
2018-11-13 11:04:03 -02:00
|
|
|
|
2019-10-04 01:20:41 +01:00
|
|
|
if (options.semiHidden) {
|
|
|
|
this.root.push(new SemiHidden());
|
|
|
|
}
|
2019-08-05 13:42:45 +03:00
|
|
|
}
|
2018-11-13 11:04:03 -02:00
|
|
|
}
|