From 8ff312b8e4a0630f3dc77bc54f2ca6a6d3f2d167 Mon Sep 17 00:00:00 2001 From: zsviczian Date: Sun, 16 Jul 2023 15:36:42 +0200 Subject: [PATCH] correct embed link for twitter (and others in the future) in the exported SVG --- src/utils/Utils.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 4bb45ae..b72d598 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -27,6 +27,10 @@ import { compressToBase64, decompressFromBase64 } from "lz-string"; import { getIMGFilename } from "./FileUtils"; import ExcalidrawScene from "../svgToExcalidraw/elements/ExcalidrawScene"; import { IMAGE_TYPES } from "../Constants"; +import { ExcalidrawAutomate } from "lib/ExcalidrawAutomate"; +import { getEA } from "src"; +import elements from "src/svgToExcalidraw/elements"; +import { generateEmbeddableLink } from "./CustomEmbeddableUtils"; declare const PLUGIN_VERSION:string; @@ -247,10 +251,17 @@ export const getSVG = async ( exportSettings: ExportSettings, padding: number, ): Promise => { - + let elements:ExcalidrawElement[] = scene.elements; + if(elements.some(el => el.type === "embeddable")) { + elements = JSON.parse(JSON.stringify(elements)); + elements.filter(el => el.type === "embeddable").forEach((el:any) => { + el.link = generateEmbeddableLink(el.link, scene.appState?.theme ?? "light"); + }); + } + try { return await exportToSvg({ - elements: scene.elements, + elements, appState: { exportBackground: exportSettings.withBackground, exportWithDarkMode: exportSettings.withTheme