Virtual whiteboard for sketching hand-drawn like diagrams
feat: Add prop UIOptions.canvasActions.saveAsImage to show/hide save image button (#3662)
Aakansha Doshi360310de312e
diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsxindex d914779e84..6052da696c 100644--- a/src/components/LayerUI.tsx+++ b/src/components/LayerUI.tsx@@ -401,7 +401,7 @@ const LayerUI = ({};const renderImageExportDialog = () => {- if (!UIOptions.canvasActions.export) {+ if (!UIOptions.canvasActions.saveAsImage) {return null;}diff --git a/src/constants.ts b/src/constants.tsindex 9ac619b1cd..b4429db0ef 100644--- a/src/constants.ts+++ b/src/constants.ts@@ -135,6 +135,7 @@ export const DEFAULT_UI_OPTIONS: AppProps["UIOptions"] = {loadScene: true,saveToActiveFile: true,theme: true,+ saveAsImage: true,},};diff --git a/src/packages/excalidraw/CHANGELOG.md b/src/packages/excalidraw/CHANGELOG.mdindex 9e3bc4634e..0d10a2e9e0 100644--- a/src/packages/excalidraw/CHANGELOG.md+++ b/src/packages/excalidraw/CHANGELOG.md@@ -17,6 +17,8 @@ Please add the latest change on the top under the correct section.### Features+- Added prop `UIOptions.canvasActions.saveAsImage` to show/hide the **Save as image** button in the canvas actions. Defauls to `true` hence the **Save as Image** button is rendered [#3662](https://github.com/excalidraw/excalidraw/pull/3662).+- Export dialog can be customised with [`UiOptions.canvasActions.export`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#exportOpts) [#3658](https://github.com/excalidraw/excalidraw/pull/3658).Also, [`UIOptions`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#UIOptions) is now memoized to avoid unnecessary rerenders.diff --git a/src/packages/excalidraw/README_NEXT.md b/src/packages/excalidraw/README_NEXT.mdindex ec7eadb240..8ebd9f60f6 100644--- a/src/packages/excalidraw/README_NEXT.md+++ b/src/packages/excalidraw/README_NEXT.md@@ -570,6 +570,7 @@ This prop can be used to customise UI of Excalidraw. Currently we support custom| `loadScene` | boolean | true | Implies whether to show `Load button` || `saveToActiveFile` | boolean | true | Implies whether to show `Save button` to save to current file || `theme` | boolean | true | Implies whether to show `Theme toggle` |+| `saveAsImage` | boolean | true | Implies whether to show `Save as image button` |#### `exportOpts`diff --git a/src/tests/excalidrawPackage.test.tsx b/src/tests/excalidrawPackage.test.tsxindex 628c27a47c..03e2a629bd 100644--- a/src/tests/excalidrawPackage.test.tsx+++ b/src/tests/excalidrawPackage.test.tsx@@ -167,6 +167,13 @@ describe("<Excalidraw/>", () => {);expect(queryByTestId(container, "json-export-button")).toBeNull();+ });++ it("should hide 'Save as image' button when 'saveAsImage' is false", async () => {+ const { container } = await render(+ <Excalidraw UIOptions={{ canvasActions: { saveAsImage: false } }} />,+ );+expect(queryByTestId(container, "image-export-button")).toBeNull();});diff --git a/src/types.ts b/src/types.tsindex 10f99dcea7..7863c0dd46 100644--- a/src/types.ts+++ b/src/types.ts@@ -230,6 +230,7 @@ type CanvasActions = {loadScene?: boolean;saveToActiveFile?: boolean;theme?: boolean;+ saveAsImage?: boolean;};export type UIOptions = {