mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
support embedding scene data to PNG/SVG (#2219)
Co-authored-by: Lipis <lipiridis@gmail.com>
This commit is contained in:
parent
7618ca48d7
commit
5950fa9a40
20 changed files with 329 additions and 27 deletions
|
@ -29,7 +29,10 @@ export const exportToCanvas = (
|
|||
viewBackgroundColor: string;
|
||||
shouldAddWatermark: boolean;
|
||||
},
|
||||
createCanvas: (width: number, height: number) => any = (width, height) => {
|
||||
createCanvas: (width: number, height: number) => HTMLCanvasElement = (
|
||||
width,
|
||||
height,
|
||||
) => {
|
||||
const tempCanvas = document.createElement("canvas");
|
||||
tempCanvas.width = width * scale;
|
||||
tempCanvas.height = height * scale;
|
||||
|
@ -44,7 +47,7 @@ export const exportToCanvas = (
|
|||
shouldAddWatermark,
|
||||
);
|
||||
|
||||
const tempCanvas: any = createCanvas(width, height);
|
||||
const tempCanvas = createCanvas(width, height);
|
||||
|
||||
renderScene(
|
||||
sceneElements,
|
||||
|
@ -81,11 +84,13 @@ export const exportToSvg = (
|
|||
exportPadding = 10,
|
||||
viewBackgroundColor,
|
||||
shouldAddWatermark,
|
||||
metadata = "",
|
||||
}: {
|
||||
exportBackground: boolean;
|
||||
exportPadding?: number;
|
||||
viewBackgroundColor: string;
|
||||
shouldAddWatermark: boolean;
|
||||
metadata?: string;
|
||||
},
|
||||
): SVGSVGElement => {
|
||||
const sceneElements = getElementsAndWatermark(elements, shouldAddWatermark);
|
||||
|
@ -104,6 +109,7 @@ export const exportToSvg = (
|
|||
|
||||
svgRoot.innerHTML = `
|
||||
${SVG_EXPORT_TAG}
|
||||
${metadata}
|
||||
<defs>
|
||||
<style>
|
||||
@font-face {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue