2020-10-05 16:46:18 +03:00
|
|
|
import { LevelJSON } from "./json";
|
2021-04-14 06:01:38 +03:00
|
|
|
import {
|
|
|
|
createDefaultParagraphProperty,
|
|
|
|
ParagraphProperty,
|
|
|
|
SpecialIndentKind,
|
2022-01-17 08:27:24 +02:00
|
|
|
} from "./paragraph-property";
|
2024-11-22 03:58:49 +02:00
|
|
|
import {
|
|
|
|
createDefaultRunProperty,
|
|
|
|
RunFonts,
|
|
|
|
RunProperty,
|
|
|
|
} from "./run-property";
|
2020-01-30 16:14:25 +02:00
|
|
|
|
2020-06-04 12:09:20 +03:00
|
|
|
export type LevelSuffixType = "nothing" | "tab" | "space";
|
|
|
|
|
2020-01-30 16:14:25 +02:00
|
|
|
export class Level {
|
|
|
|
id: number;
|
|
|
|
start: number;
|
|
|
|
format: string;
|
|
|
|
text: string;
|
|
|
|
jc: string;
|
2021-04-14 06:01:38 +03:00
|
|
|
paragraphProperty: ParagraphProperty = createDefaultParagraphProperty();
|
2024-11-22 03:58:49 +02:00
|
|
|
runProperty: RunProperty = createDefaultRunProperty();
|
2020-06-04 12:09:20 +03:00
|
|
|
levelSuffix: LevelSuffixType;
|
2020-01-30 16:14:25 +02:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
id: number,
|
|
|
|
start: number,
|
|
|
|
format: string,
|
|
|
|
text: string,
|
|
|
|
jc: string
|
|
|
|
) {
|
|
|
|
this.id = id;
|
|
|
|
this.start = start;
|
|
|
|
this.format = format;
|
|
|
|
this.text = text;
|
|
|
|
this.jc = jc;
|
2020-06-04 12:09:20 +03:00
|
|
|
this.levelSuffix = "tab";
|
2020-01-30 16:14:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
indent(
|
|
|
|
left: number,
|
|
|
|
specialIndentKind?: SpecialIndentKind,
|
|
|
|
specialIndentSize?: number
|
|
|
|
) {
|
|
|
|
this.paragraphProperty.indent = {
|
|
|
|
left,
|
|
|
|
specialIndentKind,
|
2020-06-04 11:53:37 +03:00
|
|
|
specialIndentSize,
|
2020-01-30 16:14:25 +02:00
|
|
|
};
|
|
|
|
return this;
|
|
|
|
}
|
2020-06-04 12:09:20 +03:00
|
|
|
|
|
|
|
suffix(s: LevelSuffixType) {
|
|
|
|
this.levelSuffix = s;
|
|
|
|
return this;
|
|
|
|
}
|
2020-12-14 04:42:07 +02:00
|
|
|
|
|
|
|
size(size: number) {
|
2024-11-22 03:58:49 +02:00
|
|
|
this.runProperty.size(size);
|
2020-12-14 04:42:07 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
color(color: string) {
|
2024-11-22 03:58:49 +02:00
|
|
|
this.runProperty.color(color);
|
2020-12-14 04:42:07 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
highlight(color: string) {
|
2024-11-22 03:58:49 +02:00
|
|
|
this.runProperty.highlight(color);
|
2020-12-14 04:42:07 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bold() {
|
2024-11-22 03:58:49 +02:00
|
|
|
this.runProperty.bold();
|
2020-12-14 04:42:07 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2025-01-29 05:08:57 +02:00
|
|
|
disableBold() {
|
|
|
|
this.runProperty.disableBold();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2020-12-14 04:42:07 +02:00
|
|
|
italic() {
|
2024-11-22 03:58:49 +02:00
|
|
|
this.runProperty.italic();
|
2020-12-14 04:42:07 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2025-01-29 05:08:57 +02:00
|
|
|
disableItalic() {
|
|
|
|
this.runProperty.disableItalic();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
strike() {
|
|
|
|
this.runProperty.strike();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
disableStrike() {
|
|
|
|
this.runProperty.disableStrike();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2020-12-14 04:42:07 +02:00
|
|
|
underline(type: string) {
|
2024-11-22 03:58:49 +02:00
|
|
|
this.runProperty.underline(type);
|
2020-12-14 04:42:07 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
vanish() {
|
2024-11-22 03:58:49 +02:00
|
|
|
this.runProperty.vanish();
|
2020-12-14 04:42:07 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
fonts(fonts: RunFonts) {
|
2024-11-22 03:58:49 +02:00
|
|
|
this.runProperty.fonts(fonts);
|
2020-12-14 04:42:07 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2023-06-23 13:09:27 +03:00
|
|
|
characterSpacing(characterSpacing: number) {
|
2024-11-22 03:58:49 +02:00
|
|
|
this.runProperty.spacing(characterSpacing);
|
2020-12-14 04:42:07 +02:00
|
|
|
return this;
|
|
|
|
}
|
2020-01-30 16:14:25 +02:00
|
|
|
}
|
2020-06-04 11:53:37 +03:00
|
|
|
|
|
|
|
export class LevelOverride {
|
|
|
|
level: number;
|
|
|
|
startOverride: number | null = null;
|
2020-10-05 16:46:18 +03:00
|
|
|
levelOverride: LevelJSON | null = null;
|
2020-06-04 11:53:37 +03:00
|
|
|
|
|
|
|
constructor(level: number) {
|
|
|
|
this.level = level;
|
|
|
|
}
|
|
|
|
|
2020-10-05 16:46:18 +03:00
|
|
|
overrideStart(start: number) {
|
2020-06-04 11:53:37 +03:00
|
|
|
this.startOverride = start;
|
|
|
|
return this;
|
|
|
|
}
|
2020-10-05 16:46:18 +03:00
|
|
|
|
|
|
|
overrideLevel(level: LevelJSON) {
|
|
|
|
this.levelOverride = level;
|
|
|
|
return this;
|
|
|
|
}
|
2020-06-04 11:53:37 +03:00
|
|
|
}
|