feat: expose getFreeDrawSvg, loadFromBlob and loadLibraryFromBlob from excalidraw package (#3764)

* feat: expose getFreeDrawSvg, loadFromBlob and loadLibraryFromBlob from excalidraw package

* Add docs

* fix
This commit is contained in:
Aakansha Doshi 2021-06-26 02:12:58 +05:30 committed by GitHub
parent bfc0656475
commit bdead4d164
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 3 deletions

View File

@ -19,6 +19,8 @@ Please add the latest change on the top under the correct section.
### Features
- Expose [`loadLibraryFromBlob`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#loadLibraryFromBlobY), [`loadFromBlob`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#loadFromBlob), and [`getFreeDrawSvgPath`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#getFreeDrawSvgPath).
- Expose [`FONT_FAMILY`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#FONT_FAMILY) so that consumer can use when passing `initialData.appState.currentItemFontFamily`.
- Added prop [`autoFocus`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#autoFocus) to focus the excalidraw component on page load when enabled, defaults to false [#3691](https://github.com/excalidraw/excalidraw/pull/3691).

View File

@ -843,10 +843,10 @@ This function returns a svg with the exported elements.
### FONT_FAMILY
**_Signature_**
**How to use**
```js
import { FONT_FAMILY } from "./constants";
import { FONT_FAMILY } from "@excalidraw/excalidraw-next";
```
`FONT_FAMILY` contains all the font families used in `Excalidraw` as explained below
@ -858,3 +858,49 @@ import { FONT_FAMILY } from "./constants";
| Cacadia | The Code Font |
Defaults to `FONT_FAMILY.Virgil` unless passed in `initialData.appState.currentItemFontFamily`.
### loadLibraryFromBlob
```js
import { loadLibraryFromBlob } from "@excalidraw/excalidraw-next";
```
**_Signature_**
<pre>
loadLibraryFromBlob(blob: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob">Blob</a>)
</pre>
This function loads the library from the blob.
### loadFromBlob
**How to use**
```js
import { loadFromBlob } from "@excalidraw/excalidraw-next";
```
**Signature**
<pre>
loadFromBlob(blob: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob">Blob</a>, localAppState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a> | null)
</pre>
This function loads the scene data from the blob. If you pass `localAppState`, `localAppState` value will be preferred over the `appState` derived from `blob`
### getFreeDrawSvgPath
**How to use**
```js
import { getFreeDrawSvgPath } from "@excalidraw/excalidraw-next";
```
**Signature**
<pre>
getFreeDrawSvgPath(element: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L127">ExcalidrawFreeDrawElement</a>
</pre>
This function returns the free draw svg path for the element.

View File

@ -178,6 +178,9 @@ export {
exportToCanvas,
exportToBlob,
exportToSvg,
serializeAsJSON,
loadLibraryFromBlob,
loadFromBlob,
getFreeDrawSvgPath,
} from "../../packages/utils";
export { serializeAsJSON } from "../../data/json";
export { FONT_FAMILY } from "../../constants";

View File

@ -95,3 +95,5 @@ export const exportToSvg = ({
};
export { serializeAsJSON } from "../data/json";
export { loadFromBlob, loadLibraryFromBlob } from "../data/blob";
export { getFreeDrawSvgPath } from "../renderer/renderElement";