mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: library restoring changes (#4995)
* restore library items in all cases & refactor * export `restoreLibraryItems` from package * feat: rerender library menu when updating via API * update readme & changelog * fix changelog
This commit is contained in:
parent
bf6d0eeef7
commit
70b3a9de49
6 changed files with 71 additions and 29 deletions
|
@ -15,6 +15,14 @@ Please add the latest change on the top under the correct section.
|
|||
|
||||
### Excalidraw API
|
||||
|
||||
#### Features
|
||||
|
||||
- Exported [`restoreLibraryItems`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#restoreLibraryItems) API useful when dealing with libraries [#4995](https://github.com/excalidraw/excalidraw/pull/4995).
|
||||
|
||||
#### Fixes
|
||||
|
||||
- Library menu now properly rerenders if open when library is updated using `updateScene({ libraryItems })` [#4995](https://github.com/excalidraw/excalidraw/pull/4995).
|
||||
|
||||
#### Refactor
|
||||
|
||||
- Rename `appState.elementLocked` to `appState.activeTool.locked` [#4983](https://github.com/excalidraw/excalidraw/pull/4983).
|
||||
|
|
|
@ -802,6 +802,24 @@ import { restore } from "@excalidraw/excalidraw-next";
|
|||
|
||||
This function makes sure elements and state is set to appropriate values and set to default value if not present. It is a combination of [restoreElements](#restoreElements) and [restoreAppState](#restoreAppState).
|
||||
|
||||
#### `restoreLibraryItems`
|
||||
|
||||
**_Signature_**
|
||||
|
||||
<pre>
|
||||
restoreLibraryItems(libraryItems: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L22">ImportedDataState["libraryItems"]</a>, defaultStatus: "published" | "unpublished")
|
||||
</pre>
|
||||
|
||||
**_How to use_**
|
||||
|
||||
```js
|
||||
import { restoreLibraryItems } from "@excalidraw/excalidraw-next";
|
||||
|
||||
restoreLibraryItems(libraryItems, "unpublished");
|
||||
```
|
||||
|
||||
This function normalizes library items elements, adding missing values when needed.
|
||||
|
||||
### Export utilities
|
||||
|
||||
#### `exportToCanvas`
|
||||
|
|
|
@ -177,7 +177,12 @@ export {
|
|||
getNonDeletedElements,
|
||||
} from "../../element";
|
||||
export { defaultLang, languages } from "../../i18n";
|
||||
export { restore, restoreAppState, restoreElements } from "../../data/restore";
|
||||
export {
|
||||
restore,
|
||||
restoreAppState,
|
||||
restoreElements,
|
||||
restoreLibraryItems,
|
||||
} from "../../data/restore";
|
||||
export {
|
||||
exportToCanvas,
|
||||
exportToBlob,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue