create hyperlink style
This commit is contained in:
@ -9,6 +9,7 @@ import {
|
||||
Heading4Style,
|
||||
Heading5Style,
|
||||
Heading6Style,
|
||||
HyperlinkStyle,
|
||||
ListParagraph,
|
||||
TitleStyle,
|
||||
} from "./style";
|
||||
@ -54,6 +55,8 @@ export class DefaultStylesFactory {
|
||||
// listParagraph.addParagraphProperty();
|
||||
styles.push(listParagraph);
|
||||
|
||||
const hyperLinkStyle = new HyperlinkStyle();
|
||||
styles.push(hyperLinkStyle);
|
||||
return styles;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import * as paragraph from "../../paragraph";
|
||||
import * as formatting from "../../paragraph/run/formatting";
|
||||
import { RunProperties } from "../../paragraph/run/properties";
|
||||
|
||||
import { BasedOn, Name, Next, QuickFormat } from "./components";
|
||||
import { BasedOn, Name, Next, QuickFormat, UiPriority, UnhideWhenUsed } from "./components";
|
||||
|
||||
export interface IStyleAttributes {
|
||||
type?: string;
|
||||
@ -249,3 +249,43 @@ export class ListParagraph extends ParagraphStyle {
|
||||
this.root.push(new QuickFormat());
|
||||
}
|
||||
}
|
||||
|
||||
export class CharacterStyle extends Style {
|
||||
private readonly runProperties: RunProperties;
|
||||
|
||||
constructor(styleId: string, name?: string) {
|
||||
super({ type: "character", styleId: styleId }, name);
|
||||
this.runProperties = new RunProperties();
|
||||
this.root.push(this.runProperties);
|
||||
this.root.push(new UiPriority("99"));
|
||||
this.root.push(new UnhideWhenUsed(""));
|
||||
}
|
||||
|
||||
public basedOn(parentId: string): CharacterStyle {
|
||||
this.root.push(new BasedOn(parentId));
|
||||
return this;
|
||||
}
|
||||
|
||||
public addRunProperty(property: XmlComponent): void {
|
||||
this.runProperties.push(property);
|
||||
}
|
||||
|
||||
public color(color: string): CharacterStyle {
|
||||
this.addRunProperty(new formatting.Color(color));
|
||||
return this;
|
||||
}
|
||||
|
||||
public underline(underlineType?: string, color?: string): CharacterStyle {
|
||||
this.addRunProperty(new formatting.Underline(underlineType, color));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
export class HyperlinkStyle extends CharacterStyle {
|
||||
constructor() {
|
||||
super("Hyperlink", "Hyperlink");
|
||||
this.basedOn("DefaultParagraphFont")
|
||||
.color("0563C1")
|
||||
.underline("single");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user