mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: support appState.exportEmbedScene to embed scene data in exportToSvg util (#3777)
* feat: add embedScene attribute to exportToSvg util * fix * return promise * add docs and remove * fix * fix tests * use * fix * fix * remove metadata and use exportEmbedScene * fix * fix * fix * fix * IIFE
This commit is contained in:
parent
62303b8a22
commit
f861a9fdd0
12 changed files with 128 additions and 79 deletions
|
@ -15,16 +15,16 @@ describe("exportToSvg", () => {
|
|||
viewBackgroundColor: "#ffffff",
|
||||
};
|
||||
|
||||
it("with default arguments", () => {
|
||||
const svgElement = exportUtils.exportToSvg(ELEMENTS, DEFAULT_OPTIONS);
|
||||
it("with default arguments", async () => {
|
||||
const svgElement = await exportUtils.exportToSvg(ELEMENTS, DEFAULT_OPTIONS);
|
||||
|
||||
expect(svgElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("with background color", () => {
|
||||
it("with background color", async () => {
|
||||
const BACKGROUND_COLOR = "#abcdef";
|
||||
|
||||
const svgElement = exportUtils.exportToSvg(ELEMENTS, {
|
||||
const svgElement = await exportUtils.exportToSvg(ELEMENTS, {
|
||||
...DEFAULT_OPTIONS,
|
||||
exportBackground: true,
|
||||
viewBackgroundColor: BACKGROUND_COLOR,
|
||||
|
@ -36,8 +36,8 @@ describe("exportToSvg", () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("with dark mode", () => {
|
||||
const svgElement = exportUtils.exportToSvg(ELEMENTS, {
|
||||
it("with dark mode", async () => {
|
||||
const svgElement = await exportUtils.exportToSvg(ELEMENTS, {
|
||||
...DEFAULT_OPTIONS,
|
||||
exportWithDarkMode: true,
|
||||
});
|
||||
|
@ -47,14 +47,12 @@ describe("exportToSvg", () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("with exportPadding, metadata", () => {
|
||||
const svgElement = exportUtils.exportToSvg(ELEMENTS, {
|
||||
it("with exportPadding", async () => {
|
||||
const svgElement = await exportUtils.exportToSvg(ELEMENTS, {
|
||||
...DEFAULT_OPTIONS,
|
||||
exportPadding: 0,
|
||||
metadata: "some metadata",
|
||||
});
|
||||
|
||||
expect(svgElement.innerHTML).toMatch(/some metadata/);
|
||||
expect(svgElement).toHaveAttribute("height", ELEMENT_HEIGHT.toString());
|
||||
expect(svgElement).toHaveAttribute("width", ELEMENT_WIDTH.toString());
|
||||
expect(svgElement).toHaveAttribute(
|
||||
|
@ -63,10 +61,10 @@ describe("exportToSvg", () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("with scale", () => {
|
||||
it("with scale", async () => {
|
||||
const SCALE = 2;
|
||||
|
||||
const svgElement = exportUtils.exportToSvg(ELEMENTS, {
|
||||
const svgElement = await exportUtils.exportToSvg(ELEMENTS, {
|
||||
...DEFAULT_OPTIONS,
|
||||
exportPadding: 0,
|
||||
exportScale: SCALE,
|
||||
|
@ -81,4 +79,12 @@ describe("exportToSvg", () => {
|
|||
(ELEMENT_WIDTH * SCALE).toString(),
|
||||
);
|
||||
});
|
||||
|
||||
it("with exportEmbedScene", async () => {
|
||||
const svgElement = await exportUtils.exportToSvg(ELEMENTS, {
|
||||
...DEFAULT_OPTIONS,
|
||||
exportEmbedScene: true,
|
||||
});
|
||||
expect(svgElement.innerHTML).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue