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:
Aakansha Doshi 2021-07-03 02:07:01 +05:30 committed by GitHub
parent 62303b8a22
commit f861a9fdd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 128 additions and 79 deletions

View file

@ -34,19 +34,21 @@ const ChartPreviewBtn = (props: {
0,
);
setChartElements(elements);
const svg = exportToSvg(elements, {
exportBackground: false,
viewBackgroundColor: oc.white,
});
let svg: SVGSVGElement;
const previewNode = previewRef.current!;
previewNode.appendChild(svg);
(async () => {
svg = await exportToSvg(elements, {
exportBackground: false,
viewBackgroundColor: oc.white,
});
if (props.selected) {
(previewNode.parentNode as HTMLDivElement).focus();
}
previewNode.appendChild(svg);
if (props.selected) {
(previewNode.parentNode as HTMLDivElement).focus();
}
})();
return () => {
previewNode.removeChild(svg);