Files
docx-js/src/file/drawing/drawing.ts
dependabot[bot] 2381ba8a05 build(deps-dev): bump eslint from 8.57.1 to 9.13.0 (#2792)
* build(deps-dev): bump eslint from 8.57.1 to 9.13.0

Bumps [eslint](https://github.com/eslint/eslint) from 8.57.1 to 9.13.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.57.1...v9.13.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Upgrade EsLint

* Fix all new lint errors

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dolan Miu <dolan_miu@hotmail.com>
2024-10-21 03:57:15 +01:00

48 lines
1.6 KiB
TypeScript

import { IMediaData } from "@file/media";
import { XmlComponent } from "@file/xml-components";
import { Anchor } from "./anchor";
import { DocPropertiesOptions } from "./doc-properties/doc-properties";
import { IFloating } from "./floating";
import { createInline } from "./inline";
import { OutlineOptions } from "./inline/graphic/graphic-data/pic/shape-properties/outline/outline";
export type IDistance = {
readonly distT?: number;
readonly distB?: number;
readonly distL?: number;
readonly distR?: number;
};
export type IDrawingOptions = {
readonly floating?: IFloating;
readonly docProperties?: DocPropertiesOptions;
readonly outline?: OutlineOptions;
};
// <xsd:complexType name="CT_Drawing">
// <xsd:choice minOccurs="1" maxOccurs="unbounded">
// <xsd:element ref="wp:anchor" minOccurs="0"/>
// <xsd:element ref="wp:inline" minOccurs="0"/>
// </xsd:choice>
// </xsd:complexType>
export class Drawing extends XmlComponent {
public constructor(imageData: IMediaData, drawingOptions: IDrawingOptions = {}) {
super("w:drawing");
if (!drawingOptions.floating) {
this.root.push(
createInline({
mediaData: imageData,
transform: imageData.transformation,
docProperties: drawingOptions.docProperties,
outline: drawingOptions.outline,
}),
);
} else {
this.root.push(new Anchor({ mediaData: imageData, transform: imageData.transformation, drawingOptions }));
}
}
}