Skip to content

Commit

Permalink
removed zoom controls from render, added props for new render method
Browse files Browse the repository at this point in the history
  • Loading branch information
yashu2001 committed Jun 1, 2022
1 parent 26ca72e commit 7fc7cb5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ class App extends React.Component<AppProps, AppState> {
height: window.innerHeight,
showHyperlinkPopup: false,
};

this.id = nanoid();

if (excalidrawRef) {
Expand Down Expand Up @@ -516,8 +515,8 @@ class App extends React.Component<AppProps, AppState> {
renderTopRightUI,
renderFooter,
renderCustomStats,
renderCopyDownload,
} = this.props;

return (
<div
className={clsx("excalidraw excalidraw-container", {
Expand Down Expand Up @@ -558,6 +557,7 @@ class App extends React.Component<AppProps, AppState> {
isCollaborating={this.props.isCollaborating}
renderTopRightUI={renderTopRightUI}
renderCustomFooter={renderFooter}
renderCopyDownload={renderCopyDownload}
viewModeEnabled={viewModeEnabled}
showExitZenModeBtn={
typeof this.props?.zenModeEnabled === "undefined" &&
Expand Down
21 changes: 4 additions & 17 deletions src/components/LayerUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { calculateScrollCenter, getSelectedElements } from "../scene";
import { ExportType } from "../scene/types";
import { AppProps, AppState, ExcalidrawProps, BinaryFiles } from "../types";
import { muteFSAbortError, setCursorForShape } from "../utils";
import { SelectedShapeActions, ShapesSwitcher, ZoomActions } from "./Actions";
import { SelectedShapeActions, ShapesSwitcher } from "./Actions";
import { BackgroundPickerAndDarkModeToggle } from "./BackgroundPickerAndDarkModeToggle";
import CollabButton from "./CollabButton";
import { ErrorDialog } from "./ErrorDialog";
Expand Down Expand Up @@ -69,6 +69,7 @@ interface LayerUIProps {
library: Library;
id: string;
onImageAction: (data: { insertOnCanvasDirectly: boolean }) => void;
renderCopyDownload: () => JSX.Element;
}

const LayerUI = ({
Expand Down Expand Up @@ -96,6 +97,7 @@ const LayerUI = ({
library,
id,
onImageAction,
renderCopyDownload,
}: LayerUIProps) => {
const deviceType = useDeviceType();

Expand Down Expand Up @@ -437,24 +439,8 @@ const LayerUI = ({
>
<Stack.Col gap={2}>
<Section heading="canvasActions">
<Island padding={1}>
<ZoomActions
renderAction={actionManager.renderAction}
zoom={appState.zoom}
/>
</Island>
{!viewModeEnabled && (
<>
<div
className={clsx("undo-redo-buttons zen-mode-transition", {
"layer-ui__wrapper__footer-left--transition-bottom":
zenModeEnabled,
})}
>
{actionManager.renderAction("undo", { size: "small" })}
{actionManager.renderAction("redo", { size: "small" })}
</div>

<div
className={clsx("eraser-buttons zen-mode-transition", {
"layer-ui__wrapper__footer-left--transition-left":
Expand All @@ -477,6 +463,7 @@ const LayerUI = ({
{actionManager.renderAction("finalize", { size: "small" })}
</div>
)}
{renderCopyDownload()}
</Section>
</Stack.Col>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/excalidraw-app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ const ExcalidrawWrapper = () => {
})}
>
<Excalidraw
renderCopyDownload={() => <></>}
ref={excalidrawRefCallback}
onChange={onChange}
initialData={initialStatePromiseRef.current.promise}
Expand Down
2 changes: 2 additions & 0 deletions src/packages/excalidraw/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
registerComment,
user,
deletedCommentID,
renderCopyDownload,
} = props;

const canvasActions = props.UIOptions?.canvasActions;
Expand Down Expand Up @@ -79,6 +80,7 @@ const ExcalidrawBase = (props: ExcalidrawProps) => {
<InitializeApp langCode={langCode}>
<Provider unstable_createStore={() => jotaiStore} scope={jotaiScope}>
<App
renderCopyDownload={renderCopyDownload}
onChange={onChange}
initialData={initialData}
excalidrawRef={excalidrawRef}
Expand Down
2 changes: 1 addition & 1 deletion src/packages/excalidraw/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@excalidraw/excalidraw",
"version": "0.12.6",
"version": "0.12.7",
"main": "main.js",
"types": "types/packages/excalidraw/index.d.ts",
"files": [
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ export interface ExcalidrawProps {
user?: UserProp;
registerComment: (canvasX: number, canvasY: number) => Promise<string>;
deletedCommentID?: Array<string>;
renderCopyDownload: () => JSX.Element;
}

export type UserProp = Readonly<{
Expand Down

0 comments on commit 7fc7cb5

Please sign in to comment.