mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Adding ability to copy to clipboard as SVG (#1250)
This commit is contained in:
parent
2de4fe29ad
commit
d5366db341
5 changed files with 55 additions and 7 deletions
|
@ -7,7 +7,10 @@ import { exportToCanvas, exportToSvg } from "../scene/export";
|
|||
import { fileSave } from "browser-nativefs";
|
||||
|
||||
import { t } from "../i18n";
|
||||
import { copyCanvasToClipboardAsPng } from "../clipboard";
|
||||
import {
|
||||
copyCanvasToClipboardAsPng,
|
||||
copyCanvasToClipboardAsSvg,
|
||||
} from "../clipboard";
|
||||
import { serializeAsJSON } from "./json";
|
||||
|
||||
import { ExportType } from "../scene/types";
|
||||
|
@ -299,16 +302,21 @@ export async function exportCanvas(
|
|||
if (!hasNonDeletedElements(elements)) {
|
||||
return window.alert(t("alerts.cannotExportEmptyCanvas"));
|
||||
}
|
||||
if (type === "svg") {
|
||||
if (type === "svg" || type === "clipboard-svg") {
|
||||
const tempSvg = exportToSvg(elements, {
|
||||
exportBackground,
|
||||
viewBackgroundColor,
|
||||
exportPadding,
|
||||
});
|
||||
await fileSave(new Blob([tempSvg.outerHTML], { type: "image/svg+xml" }), {
|
||||
fileName: `${name}.svg`,
|
||||
});
|
||||
return;
|
||||
if (type === "svg") {
|
||||
await fileSave(new Blob([tempSvg.outerHTML], { type: "image/svg+xml" }), {
|
||||
fileName: `${name}.svg`,
|
||||
});
|
||||
return;
|
||||
} else if (type === "clipboard-svg") {
|
||||
copyCanvasToClipboardAsSvg(tempSvg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const tempCanvas = exportToCanvas(elements, appState, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue