|
@@ -18,11 +18,6 @@ const probablySupportsClipboard =
|
|
"write" in navigator.clipboard &&
|
|
"write" in navigator.clipboard &&
|
|
"ClipboardItem" in window;
|
|
"ClipboardItem" in window;
|
|
|
|
|
|
-const scales = [1, 2, 3];
|
|
|
|
-const defaultScale = scales.includes(devicePixelRatio) ? devicePixelRatio : 1;
|
|
|
|
-
|
|
|
|
-type ExportCB = (elements: readonly ExcalidrawElement[], scale: number) => void;
|
|
|
|
-
|
|
|
|
export function ExportDialog({
|
|
export function ExportDialog({
|
|
elements,
|
|
elements,
|
|
appState,
|
|
appState,
|
|
@@ -37,12 +32,11 @@ export function ExportDialog({
|
|
exportPadding?: number;
|
|
exportPadding?: number;
|
|
actionManager: ActionsManagerInterface;
|
|
actionManager: ActionsManagerInterface;
|
|
syncActionResult: UpdaterFn;
|
|
syncActionResult: UpdaterFn;
|
|
- onExportToPng: ExportCB;
|
|
|
|
- onExportToClipboard: ExportCB;
|
|
|
|
|
|
+ onExportToPng(elements: readonly ExcalidrawElement[]): void;
|
|
|
|
+ onExportToClipboard(elements: readonly ExcalidrawElement[]): void;
|
|
}) {
|
|
}) {
|
|
const someElementIsSelected = elements.some(element => element.isSelected);
|
|
const someElementIsSelected = elements.some(element => element.isSelected);
|
|
const [modalIsShown, setModalIsShown] = useState(false);
|
|
const [modalIsShown, setModalIsShown] = useState(false);
|
|
- const [scale, setScale] = useState(defaultScale);
|
|
|
|
const [exportSelected, setExportSelected] = useState(someElementIsSelected);
|
|
const [exportSelected, setExportSelected] = useState(someElementIsSelected);
|
|
const previeRef = useRef<HTMLDivElement>(null);
|
|
const previeRef = useRef<HTMLDivElement>(null);
|
|
const { exportBackground, viewBackgroundColor } = appState;
|
|
const { exportBackground, viewBackgroundColor } = appState;
|
|
@@ -60,8 +54,7 @@ export function ExportDialog({
|
|
const canvas = getExportCanvasPreview(exportedElements, {
|
|
const canvas = getExportCanvasPreview(exportedElements, {
|
|
exportBackground,
|
|
exportBackground,
|
|
viewBackgroundColor,
|
|
viewBackgroundColor,
|
|
- exportPadding,
|
|
|
|
- scale
|
|
|
|
|
|
+ exportPadding
|
|
});
|
|
});
|
|
previewNode?.appendChild(canvas);
|
|
previewNode?.appendChild(canvas);
|
|
return () => {
|
|
return () => {
|
|
@@ -72,8 +65,7 @@ export function ExportDialog({
|
|
exportedElements,
|
|
exportedElements,
|
|
exportBackground,
|
|
exportBackground,
|
|
exportPadding,
|
|
exportPadding,
|
|
- viewBackgroundColor,
|
|
|
|
- scale
|
|
|
|
|
|
+ viewBackgroundColor
|
|
]);
|
|
]);
|
|
|
|
|
|
function handleClose() {
|
|
function handleClose() {
|
|
@@ -106,7 +98,7 @@ export function ExportDialog({
|
|
icon={downloadFile}
|
|
icon={downloadFile}
|
|
title="Export to PNG"
|
|
title="Export to PNG"
|
|
aria-label="Export to PNG"
|
|
aria-label="Export to PNG"
|
|
- onClick={() => onExportToPng(exportedElements, scale)}
|
|
|
|
|
|
+ onClick={() => onExportToPng(exportedElements)}
|
|
/>
|
|
/>
|
|
|
|
|
|
{probablySupportsClipboard && (
|
|
{probablySupportsClipboard && (
|
|
@@ -115,9 +107,7 @@ export function ExportDialog({
|
|
icon={clipboard}
|
|
icon={clipboard}
|
|
title="Copy to clipboard"
|
|
title="Copy to clipboard"
|
|
aria-label="Copy to clipboard"
|
|
aria-label="Copy to clipboard"
|
|
- onClick={() =>
|
|
|
|
- onExportToClipboard(exportedElements, scale)
|
|
|
|
- }
|
|
|
|
|
|
+ onClick={() => onExportToClipboard(exportedElements)}
|
|
/>
|
|
/>
|
|
)}
|
|
)}
|
|
</Stack.Row>
|
|
</Stack.Row>
|
|
@@ -129,21 +119,6 @@ export function ExportDialog({
|
|
syncActionResult
|
|
syncActionResult
|
|
)}
|
|
)}
|
|
<Stack.Col gap={1}>
|
|
<Stack.Col gap={1}>
|
|
- <div className="ExportDialog__scales">
|
|
|
|
- <Stack.Row gap={1} align="baseline">
|
|
|
|
- {scales.map(s => (
|
|
|
|
- <ToolIcon
|
|
|
|
- size="s"
|
|
|
|
- type="radio"
|
|
|
|
- icon={"x" + s}
|
|
|
|
- name="export-canvas-scale"
|
|
|
|
- id="export-canvas-scale"
|
|
|
|
- checked={scale === s}
|
|
|
|
- onChange={() => setScale(s)}
|
|
|
|
- />
|
|
|
|
- ))}
|
|
|
|
- </Stack.Row>
|
|
|
|
- </div>
|
|
|
|
{actionManager.renderAction(
|
|
{actionManager.renderAction(
|
|
"changeExportBackground",
|
|
"changeExportBackground",
|
|
elements,
|
|
elements,
|