feat: support updating library in updateScene API (#4546)

* feat: support updating library in updateScene API

* fix

* update docs

* Update src/packages/excalidraw/CHANGELOG.md
This commit is contained in:
Aakansha Doshi 2022-01-06 21:37:33 +05:30 committed by GitHub
parent 5f1616f2c5
commit b475412199
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 9 deletions

View file

@ -19,6 +19,8 @@ Please add the latest change on the top under the correct section.
### Features
- Support updating library using [`updateScene`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#updateScene) API [#4546](https://github.com/excalidraw/excalidraw/pull/4546).
- Introduced primary colors to the app. The colors can be overriden. Check [readme](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#customizing-styles) on how to do so.
- #### BREAKING CHANGE

View file

@ -509,6 +509,7 @@ You can use this function to update the scene with the sceneData. It accepts the
| `appState` | [`ImportedDataState["appState"]`](https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L18) | The `appState` to be updated in the scene. |
| `collaborators` | <pre>Map<string, <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L29">Collaborator></a></pre> | The list of collaborators to be updated in the scene. |
| `commitToHistory` | `boolean` | Implies if the `history (undo/redo)` should be recorded. Defaults to `false`. |
| `libraryItems` | [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L258) | The `libraryItems` to be update in the scene. |
### `addFiles`

View file

@ -103,6 +103,24 @@ export default function App() {
>
Reset Scene
</button>
<button
onClick={() => {
excalidrawRef.current.updateScene({
libraryItems: [
{
status: "published",
elements: initialData.libraryItems[0],
},
{
status: "unpublished",
elements: initialData.libraryItems[1],
},
],
});
}}
>
Update Library
</button>
<label>
<input
type="checkbox"