Turn Run into a declaritive API
This commit is contained in:
@ -1,9 +1,19 @@
|
||||
import { Run } from "../run";
|
||||
import { IRunOptions, Run } from "./run";
|
||||
import { Text } from "./run-components/text";
|
||||
|
||||
export interface ITextRunOptions extends IRunOptions {
|
||||
readonly text: string;
|
||||
}
|
||||
|
||||
export class TextRun extends Run {
|
||||
constructor(text: string) {
|
||||
super();
|
||||
this.root.push(new Text(text));
|
||||
constructor(options: ITextRunOptions | string) {
|
||||
if (typeof options === "string") {
|
||||
super({});
|
||||
this.root.push(new Text(options));
|
||||
return;
|
||||
}
|
||||
|
||||
super(options);
|
||||
this.root.push(new Text(options.text));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user