diff --git a/src/packages/excalidraw/CHANGELOG.md b/src/packages/excalidraw/CHANGELOG.md index 0eb239d0e..901e7ef89 100644 --- a/src/packages/excalidraw/CHANGELOG.md +++ b/src/packages/excalidraw/CHANGELOG.md @@ -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). diff --git a/src/packages/excalidraw/README_NEXT.md b/src/packages/excalidraw/README_NEXT.md index df2183a32..1c0c010a0 100644 --- a/src/packages/excalidraw/README_NEXT.md +++ b/src/packages/excalidraw/README_NEXT.md @@ -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_** + +
+loadLibraryFromBlob(blob: Blob)
+
+ +This function loads the library from the blob. + +### loadFromBlob + +**How to use** + +```js +import { loadFromBlob } from "@excalidraw/excalidraw-next"; +``` + +**Signature** + +
+loadFromBlob(blob: Blob, localAppState:  AppState | null)
+
+ +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** + +
+getFreeDrawSvgPath(element: ExcalidrawFreeDrawElement
+
+ +This function returns the free draw svg path for the element. diff --git a/src/packages/excalidraw/index.tsx b/src/packages/excalidraw/index.tsx index c2d2f74df..1291bb0a5 100644 --- a/src/packages/excalidraw/index.tsx +++ b/src/packages/excalidraw/index.tsx @@ -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"; diff --git a/src/packages/utils.ts b/src/packages/utils.ts index 97196a656..3fb446f67 100644 --- a/src/packages/utils.ts +++ b/src/packages/utils.ts @@ -95,3 +95,5 @@ export const exportToSvg = ({ }; export { serializeAsJSON } from "../data/json"; +export { loadFromBlob, loadLibraryFromBlob } from "../data/blob"; +export { getFreeDrawSvgPath } from "../renderer/renderElement";