Files
docx-js/src/file/drawing/inline/graphic/graphic.ts

36 lines
888 B
TypeScript
Raw Normal View History

2018-12-21 01:39:20 +00:00
import { IMediaData } from "file/media";
2018-03-24 19:06:10 +00:00
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
2018-12-21 01:39:20 +00:00
2018-03-24 19:06:10 +00:00
import { GraphicData } from "./graphic-data";
interface IGraphicProperties {
readonly a: string;
2018-03-24 19:06:10 +00:00
}
class GraphicAttributes extends XmlAttributeComponent<IGraphicProperties> {
protected readonly xmlKeys = {
2018-03-24 19:06:10 +00:00
a: "xmlns:a",
};
}
export class Graphic extends XmlComponent {
2018-08-07 01:38:15 +01:00
private readonly data: GraphicData;
2018-03-24 19:06:10 +00:00
2018-12-21 01:39:20 +00:00
constructor(mediaData: IMediaData, x: number, y: number) {
2018-03-24 19:06:10 +00:00
super("a:graphic");
this.root.push(
new GraphicAttributes({
a: "http://schemas.openxmlformats.org/drawingml/2006/main",
}),
);
2018-12-21 01:39:20 +00:00
this.data = new GraphicData(mediaData, x, y);
2018-03-24 19:06:10 +00:00
this.root.push(this.data);
}
public setXY(x: number, y: number): void {
this.data.setXY(x, y);
}
}