Skip to content

Commit

Permalink
export duplicate helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelle committed Nov 10, 2023
1 parent a7c19f3 commit c76aaa8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/packages/excalidraw/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,5 @@ export { libraryItemsAtom } from "../../data/library";

export * as icons from "../../components/icons";
export * as actions from "../../actions/index";

export { duplicateElements, duplicateElement } from "../../element/newElement";
9 changes: 1 addition & 8 deletions src/scene/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
getElementAbsoluteCoords,
} from "../element/bounds";
import { renderStaticScene, renderSceneToSvg } from "../renderer/renderScene";
import { distance, getFontString, isOnlyExportingSingleFrame } from "../utils";
import { distance, getFontString } from "../utils";
import { AppState, BinaryFiles } from "../types";
import {
DEFAULT_BACKGROUND_COLOR,
Expand Down Expand Up @@ -541,13 +541,6 @@ export const exportToCanvas = async ({
? cfg.createCanvas()
: document.createElement("canvas");

const onlyExportingSingleFrame = isOnlyExportingSingleFrame(elements);

// hack fix until we decide whose responsibility this should be
if (onlyExportingSingleFrame) {
cfg.padding = 0;
}

// rescale padding based on current canvasScale factor so that the resulting
// padding is kept the same as supplied by user (with the exception of
// `cfg.scale` being set, which also scales the padding)
Expand Down
13 changes: 0 additions & 13 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,19 +821,6 @@ export const composeEventHandlers = <E>(
};
};

export const isOnlyExportingSingleFrame = (
elements: readonly NonDeletedExcalidrawElement[],
) => {
const frames = elements.filter((element) => element.type === "frame");

return (
frames.length === 1 &&
elements.every(
(element) => element.type === "frame" || element.frameId === frames[0].id,
)
);
};

/**
* supply `null` as message if non-never value is valid, you just need to
* typecheck against it
Expand Down

0 comments on commit c76aaa8

Please sign in to comment.