diff --git a/src/file/paragraph/links/bookmark.ts b/src/file/paragraph/links/bookmark.ts index addf14530e..261a756864 100644 --- a/src/file/paragraph/links/bookmark.ts +++ b/src/file/paragraph/links/bookmark.ts @@ -4,10 +4,6 @@ import * as shortid from "shortid"; import { TextRun } from "../run"; import { BookmarkEndAttributes, BookmarkStartAttributes } from "./bookmark-attributes"; -export class BookmarkRef { - constructor(public readonly name: string, public readonly text: string) {} -} - export class Bookmark { public readonly start: BookmarkStart; public readonly text: TextRun; diff --git a/src/file/paragraph/links/hyperlink.spec.ts b/src/file/paragraph/links/hyperlink.spec.ts index 93b59e07b6..4b06a933f5 100644 --- a/src/file/paragraph/links/hyperlink.spec.ts +++ b/src/file/paragraph/links/hyperlink.spec.ts @@ -3,6 +3,7 @@ import { expect } from "chai"; import { Formatter } from "export/formatter"; import { Hyperlink } from "./"; +import { HyperlinkRef } from "./hyperlink"; describe("Hyperlink", () => { let hyperlink: Hyperlink; @@ -59,3 +60,11 @@ describe("Hyperlink", () => { }); }); }); + +describe("HyperlinkRef", () => { + describe("#constructor()", () => { + const hyperlinkRef = new HyperlinkRef("test-id"); + + expect(hyperlinkRef.id).to.equal("test-id"); + }); +}); diff --git a/src/file/paragraph/paragraph.ts b/src/file/paragraph/paragraph.ts index c1a8861568..c97d8d34fd 100644 --- a/src/file/paragraph/paragraph.ts +++ b/src/file/paragraph/paragraph.ts @@ -13,7 +13,7 @@ import { ContextualSpacing, ISpacingProperties, Spacing } from "./formatting/spa import { HeadingLevel, Style } from "./formatting/style"; import { LeaderType, TabStop, TabStopPosition, TabStopType } from "./formatting/tab-stop"; import { NumberProperties } from "./formatting/unordered-list"; -import { Bookmark, BookmarkRef, HyperlinkRef, OutlineLevel } from "./links"; +import { Bookmark, HyperlinkRef, OutlineLevel } from "./links"; import { ParagraphProperties } from "./properties"; import { PictureRun, Run, SequentialIdentifier, SymbolRun, TextRun } from "./run"; @@ -46,7 +46,7 @@ export interface IParagraphOptions { readonly custom?: boolean; }; readonly children?: Array< - TextRun | PictureRun | SymbolRun | Bookmark | PageBreak | SequentialIdentifier | FootnoteReferenceRun | HyperlinkRef | BookmarkRef + TextRun | PictureRun | SymbolRun | Bookmark | PageBreak | SequentialIdentifier | FootnoteReferenceRun | HyperlinkRef >; } diff --git a/src/file/paragraph/run/picture-run.ts b/src/file/paragraph/run/picture-run.ts index c796beebfc..e98dba573a 100644 --- a/src/file/paragraph/run/picture-run.ts +++ b/src/file/paragraph/run/picture-run.ts @@ -7,10 +7,6 @@ export class PictureRun extends Run { constructor(imageData: IMediaData, drawingOptions?: IDrawingOptions) { super({}); - if (imageData === undefined) { - throw new Error("imageData cannot be undefined"); - } - const drawing = new Drawing(imageData, drawingOptions); this.root.push(drawing); diff --git a/src/file/paragraph/run/run.spec.ts b/src/file/paragraph/run/run.spec.ts index 37aadfb8d8..b5febf199e 100644 --- a/src/file/paragraph/run/run.spec.ts +++ b/src/file/paragraph/run/run.spec.ts @@ -132,6 +132,30 @@ describe("Run", () => { }); }); + describe("#subScript()", () => { + it("it should add subScript to the properties", () => { + const run = new Run({ + subScript: true, + }); + const tree = new Formatter().format(run); + expect(tree).to.deep.equal({ + "w:r": [{ "w:rPr": [{ "w:vertAlign": { _attr: { "w:val": "subscript" } } }] }], + }); + }); + }); + + describe("#superScript()", () => { + it("it should add superScript to the properties", () => { + const run = new Run({ + superScript: true, + }); + const tree = new Formatter().format(run); + expect(tree).to.deep.equal({ + "w:r": [{ "w:rPr": [{ "w:vertAlign": { _attr: { "w:val": "superscript" } } }] }], + }); + }); + }); + describe("#highlight()", () => { it("it should add highlight to the properties", () => { const run = new Run({