New Textbox Component (#2718)
* Adding textbox with no props * Fixing namings and adding shape style * simplify usage * Fix linting issues * Re-name demo * Use new shape authoring style * Add tests Simplify API * Add better types for styles * Add more options to TextBox and add documentation --------- Co-authored-by: zohar11 <zohar@sumit-ai.com> Co-authored-by: Dolan <dolan_miu@hotmail.com>
This commit is contained in:
committed by
GitHub
parent
c6bb255641
commit
3654eb0800
47
src/file/textbox/textbox.spec.ts
Normal file
47
src/file/textbox/textbox.spec.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { Formatter } from "@export/formatter";
|
||||
import { Paragraph } from "@file/paragraph";
|
||||
|
||||
import { Textbox } from "./textbox";
|
||||
|
||||
describe("VmlTextbox", () => {
|
||||
it("should work", () => {
|
||||
const tree = new Formatter().format(
|
||||
new Textbox({
|
||||
style: {
|
||||
width: "10pt",
|
||||
},
|
||||
children: [new Paragraph("test-content")],
|
||||
}),
|
||||
);
|
||||
|
||||
expect(tree).toStrictEqual({
|
||||
"w:p": [
|
||||
{
|
||||
"w:pict": [
|
||||
{
|
||||
"v:shape": [
|
||||
{ _attr: { id: expect.any(String), type: "#_x0000_t202", style: "width:10pt" } },
|
||||
{
|
||||
"v:textbox": [
|
||||
{ _attr: { insetmode: "auto", style: "mso-fit-shape-to-text:t;" } },
|
||||
{
|
||||
"w:txbxContent": [
|
||||
{
|
||||
"w:p": [
|
||||
{ "w:r": [{ "w:t": [{ _attr: { "xml:space": "preserve" } }, "test-content"] }] },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user