feat: export serializeAsJSON
from package (#3538)
Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
This commit is contained in:
parent
92c7d3257f
commit
8068d1f853
@ -15,6 +15,9 @@ Please add the latest change on the top under the correct section.
|
|||||||
|
|
||||||
## Excalidraw API
|
## 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).
|
- 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.
|
This also removes the GitHub icon, keeping it local to the https://excalidraw.com app.
|
||||||
|
@ -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)
|
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
|
### Export utilities
|
||||||
|
|
||||||
#### `exportToCanvas`
|
#### `exportToCanvas`
|
||||||
@ -780,7 +793,7 @@ exportToSvg({
|
|||||||
appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a>,
|
appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a>,
|
||||||
exportPadding?: number,
|
exportPadding?: number,
|
||||||
metadata?: string,
|
metadata?: string,
|
||||||
}
|
})
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|
@ -127,3 +127,4 @@ export {
|
|||||||
exportToBlob,
|
exportToBlob,
|
||||||
exportToSvg,
|
exportToSvg,
|
||||||
} from "../../packages/utils";
|
} from "../../packages/utils";
|
||||||
|
export { serializeAsJSON } from "../../data/json";
|
||||||
|
@ -97,3 +97,5 @@ export const exportToSvg = ({
|
|||||||
metadata,
|
metadata,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export { serializeAsJSON } from "../data/json";
|
||||||
|
@ -14,6 +14,10 @@ yarn add @excalidraw/utils
|
|||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
|
### `serializeAsJSON`
|
||||||
|
|
||||||
|
See [`serializeAsJSON`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#serializeAsJSON) for API and description.
|
||||||
|
|
||||||
### `exportToBlob` (async)
|
### `exportToBlob` (async)
|
||||||
|
|
||||||
Export an Excalidraw diagram to a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
|
Export an Excalidraw diagram to a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user