Virtual whiteboard for sketching hand-drawn like diagrams
feat: export `serializeAsJSON` from package (#3538)
David Luzar8068d1f8533d
diff --git a/src/packages/excalidraw/CHANGELOG.md b/src/packages/excalidraw/CHANGELOG.mdindex 5b223aaa42..3de5552b06 100644--- a/src/packages/excalidraw/CHANGELOG.md+++ b/src/packages/excalidraw/CHANGELOG.md@@ -15,6 +15,9 @@ Please add the latest change on the top under the correct section.## Excalidraw API+### Features++- Expose [`serializeAsJSON`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#serializeAsJSON) helper that we use when saving Excalidraw scene to a file [#3538](https://github.com/excalidraw/excalidraw/pull/3538).- Add support to render custom UI in the top right corner via [`renderTopRight`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#renderTopRight) prop [#3539](https://github.com/excalidraw/excalidraw/pull/3539).This also removes the GitHub icon, keeping it local to the https://excalidraw.com app.diff --git a/src/packages/excalidraw/README_NEXT.md b/src/packages/excalidraw/README_NEXT.mdindex 2e71b5bc11..a51186815c 100644--- a/src/packages/excalidraw/README_NEXT.md+++ b/src/packages/excalidraw/README_NEXT.md@@ -716,6 +716,19 @@ import { restore } from "@excalidraw/excalidraw";This function makes sure elements and state is set to appropriate values and set to default value if not present. It is combination of [restoreElements](#restoreElements) and [restoreAppState](#restoreAppState)+#### `serializeAsJSON`++**_Signature_**++<pre>+serializeAsJSON({+ elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement[]</a>,+ appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a>,+}): string+</pre>++Takes the scene elements and state and returns a JSON string. Deleted `elements`as well as most properties from `AppState` are removed from the resulting JSON. (see [`serializeAsJSON()`](https://github.com/excalidraw/excalidraw/blob/master/src/data/json.ts#L16) source for details).+### Export utilities#### `exportToCanvas`@@ -780,7 +793,7 @@ exportToSvg({appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a>,exportPadding?: number,metadata?: string,-}+})</pre>| Name | Type | Default | Description |diff --git a/src/packages/excalidraw/index.tsx b/src/packages/excalidraw/index.tsxindex 2922a7f1ae..017e7b7df5 100644--- a/src/packages/excalidraw/index.tsx+++ b/src/packages/excalidraw/index.tsx@@ -127,3 +127,4 @@ export {exportToBlob,exportToSvg,} from "../../packages/utils";+export { serializeAsJSON } from "../../data/json";diff --git a/src/packages/utils.ts b/src/packages/utils.tsindex 9749ee79fe..b26499dda5 100644--- a/src/packages/utils.ts+++ b/src/packages/utils.ts@@ -97,3 +97,5 @@ export const exportToSvg = ({metadata,});};++export { serializeAsJSON } from "../data/json";diff --git a/src/packages/utils/README.md b/src/packages/utils/README.mdindex 15ef2e4297..420f49f1fc 100644--- a/src/packages/utils/README.md+++ b/src/packages/utils/README.md@@ -14,6 +14,10 @@ yarn add @excalidraw/utils## API+### `serializeAsJSON`++See [`serializeAsJSON`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#serializeAsJSON) for API and description.+### `exportToBlob` (async)Export an Excalidraw diagram to a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob).