add support for floating drawings
- added need elements and test for them
This commit is contained in:
5
src/file/drawing/text-wrap/index.ts
Normal file
5
src/file/drawing/text-wrap/index.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export * from "./text-wrapping";
|
||||
export * from "./wrap-none";
|
||||
export * from "./wrap-square";
|
||||
export * from "./wrap-tight";
|
||||
export * from "./wrap-top-and-bottom";
|
22
src/file/drawing/text-wrap/text-wrapping.ts
Normal file
22
src/file/drawing/text-wrap/text-wrapping.ts
Normal file
@ -0,0 +1,22 @@
|
||||
// http://officeopenxml.com/drwPicFloating-textWrap.php
|
||||
import { Distance } from "../drawing";
|
||||
|
||||
export enum TextWrapStyle {
|
||||
NONE,
|
||||
SQUARE,
|
||||
TIGHT,
|
||||
TOP_AND_BOTTOM,
|
||||
}
|
||||
|
||||
export enum WrapTextOption {
|
||||
BOTH_SIDES = "bothSides",
|
||||
LEFT = "left",
|
||||
RIGHT = "right",
|
||||
LARGEST = "largest",
|
||||
}
|
||||
|
||||
export interface TextWrapping {
|
||||
textWrapStyle: TextWrapStyle;
|
||||
wrapTextOption?: WrapTextOption;
|
||||
distanceFromText?: Distance;
|
||||
}
|
8
src/file/drawing/text-wrap/wrap-none.ts
Normal file
8
src/file/drawing/text-wrap/wrap-none.ts
Normal file
@ -0,0 +1,8 @@
|
||||
// http://officeopenxml.com/drwPicFloating-textWrap.php
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
|
||||
export class WrapNone extends XmlComponent {
|
||||
constructor() {
|
||||
super("wp:wrapNone");
|
||||
}
|
||||
}
|
31
src/file/drawing/text-wrap/wrap-square.ts
Normal file
31
src/file/drawing/text-wrap/wrap-square.ts
Normal file
@ -0,0 +1,31 @@
|
||||
// http://officeopenxml.com/drwPicFloating-textWrap.php
|
||||
import { XmlComponent, XmlAttributeComponent } from "file/xml-components";
|
||||
import { TextWrapping, WrapTextOption } from ".";
|
||||
import { Distance } from "../drawing";
|
||||
|
||||
interface IWrapSquareAttributes extends Distance {
|
||||
wrapText?: WrapTextOption;
|
||||
}
|
||||
|
||||
class WrapSquareAttributes extends XmlAttributeComponent<IWrapSquareAttributes> {
|
||||
protected xmlKeys = {
|
||||
distT: "distT",
|
||||
distB: "distB",
|
||||
distL: "distL",
|
||||
distR: "distR",
|
||||
wrapText: "wrapText",
|
||||
};
|
||||
}
|
||||
|
||||
export class WrapSquare extends XmlComponent {
|
||||
constructor(textWrapping: TextWrapping) {
|
||||
super("wp:wrapSquare");
|
||||
|
||||
this.root.push(
|
||||
new WrapSquareAttributes({
|
||||
wrapText: textWrapping.wrapTextOption || WrapTextOption.BOTH_SIDES,
|
||||
...textWrapping.distanceFromText,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
33
src/file/drawing/text-wrap/wrap-tight.ts
Normal file
33
src/file/drawing/text-wrap/wrap-tight.ts
Normal file
@ -0,0 +1,33 @@
|
||||
// http://officeopenxml.com/drwPicFloating-textWrap.php
|
||||
import { XmlComponent, XmlAttributeComponent } from "file/xml-components";
|
||||
import { Distance } from "../drawing";
|
||||
|
||||
interface IWrapTightAttributes {
|
||||
distT?: number;
|
||||
distB?: number;
|
||||
}
|
||||
|
||||
class WrapTightAttributes extends XmlAttributeComponent<IWrapTightAttributes> {
|
||||
protected xmlKeys = {
|
||||
distT: "distT",
|
||||
distB: "distB",
|
||||
};
|
||||
}
|
||||
|
||||
export class WrapTight extends XmlComponent {
|
||||
constructor(distanceFromText?: Distance) {
|
||||
super("wp:wrapTight");
|
||||
|
||||
distanceFromText = distanceFromText || {
|
||||
distT: 0,
|
||||
distB: 0,
|
||||
};
|
||||
|
||||
this.root.push(
|
||||
new WrapTightAttributes({
|
||||
distT: distanceFromText.distT,
|
||||
distB: distanceFromText.distB,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
33
src/file/drawing/text-wrap/wrap-top-and-bottom.ts
Normal file
33
src/file/drawing/text-wrap/wrap-top-and-bottom.ts
Normal file
@ -0,0 +1,33 @@
|
||||
// http://officeopenxml.com/drwPicFloating-textWrap.php
|
||||
import { XmlComponent, XmlAttributeComponent } from "file/xml-components";
|
||||
import { Distance } from "../drawing";
|
||||
|
||||
interface IWrapTopAndBottomAttributes {
|
||||
distT?: number;
|
||||
distB?: number;
|
||||
}
|
||||
|
||||
class WrapTopAndBottomAttributes extends XmlAttributeComponent<IWrapTopAndBottomAttributes> {
|
||||
protected xmlKeys = {
|
||||
distT: "distT",
|
||||
distB: "distB",
|
||||
};
|
||||
}
|
||||
|
||||
export class WrapTopAndBottom extends XmlComponent {
|
||||
constructor(distanceFromText?: Distance) {
|
||||
super("wp:wrapTopAndBottom");
|
||||
|
||||
distanceFromText = distanceFromText || {
|
||||
distT: 0,
|
||||
distB: 0,
|
||||
};
|
||||
|
||||
this.root.push(
|
||||
new WrapTopAndBottomAttributes({
|
||||
distT: distanceFromText.distT,
|
||||
distB: distanceFromText.distB,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user