@zsviczian/excalidraw 0.11.0-obsidian-21-namedexport → 0.12.0-obsidian-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +352 -42
  2. package/dist/excalidraw.development.js +186 -149
  3. package/dist/excalidraw.production.min.js +1 -1
  4. package/dist/excalidraw.production.min.js.LICENSE.txt +2 -1
  5. package/package.json +22 -24
  6. package/types/actions/actionAddToLibrary.d.ts +19 -6
  7. package/types/actions/actionAlign.d.ts +6 -6
  8. package/types/actions/actionBoundText.d.ts +7 -2
  9. package/types/actions/actionCanvas.d.ts +70 -25
  10. package/types/actions/actionClipboard.d.ts +35 -10
  11. package/types/actions/actionDeleteSelected.d.ts +22 -7
  12. package/types/actions/actionDistribute.d.ts +2 -2
  13. package/types/actions/actionDuplicateSelection.d.ts +1 -1
  14. package/types/actions/actionExport.d.ts +69 -26
  15. package/types/actions/actionFinalize.d.ts +16 -6
  16. package/types/actions/actionGroup.d.ts +2 -2
  17. package/types/actions/actionMenu.d.ts +24 -9
  18. package/types/actions/actionNavigate.d.ts +1 -2
  19. package/types/actions/actionProperties.d.ts +104 -39
  20. package/types/actions/actionSelectAll.d.ts +2 -1
  21. package/types/actions/actionStyles.d.ts +5 -2
  22. package/types/actions/actionToggleGridMode.d.ts +7 -2
  23. package/types/actions/actionToggleStats.d.ts +7 -2
  24. package/types/actions/actionToggleViewMode.d.ts +7 -2
  25. package/types/actions/actionToggleZenMode.d.ts +7 -2
  26. package/types/actions/actionZindex.d.ts +4 -4
  27. package/types/analytics.d.ts +1 -1
  28. package/types/appState.d.ts +3 -0
  29. package/types/clients.d.ts +1 -1
  30. package/types/components/ActiveFile.d.ts +0 -1
  31. package/types/components/App.d.ts +17 -8
  32. package/types/components/ButtonIconSelect.d.ts +0 -1
  33. package/types/components/Card.d.ts +1 -0
  34. package/types/components/CheckboxItem.d.ts +1 -0
  35. package/types/components/ClearCanvas.d.ts +0 -1
  36. package/types/components/CollabButton.d.ts +0 -1
  37. package/types/components/ColorPicker.d.ts +0 -1
  38. package/types/components/ConfirmDialog.d.ts +0 -1
  39. package/types/components/DarkModeToggle.d.ts +0 -1
  40. package/types/components/ErrorDialog.d.ts +0 -1
  41. package/types/components/HelpDialog.d.ts +0 -1
  42. package/types/components/HelpIcon.d.ts +0 -1
  43. package/types/components/HintViewer.d.ts +0 -1
  44. package/types/components/IconPicker.d.ts +0 -1
  45. package/types/components/ImageExportDialog.d.ts +0 -1
  46. package/types/components/JSONExportDialog.d.ts +0 -1
  47. package/types/components/LayerUI.d.ts +4 -6
  48. package/types/components/LibraryMenu.d.ts +0 -1
  49. package/types/components/LibraryMenuItems.d.ts +2 -1
  50. package/types/components/LibraryUnit.d.ts +0 -1
  51. package/types/components/LockButton.d.ts +0 -1
  52. package/types/components/MobileMenu.d.ts +2 -2
  53. package/types/components/Modal.d.ts +2 -2
  54. package/types/components/PenModeButton.d.ts +0 -1
  55. package/types/components/ProjectName.d.ts +0 -1
  56. package/types/components/PublishLibrary.d.ts +0 -1
  57. package/types/components/Section.d.ts +4 -5
  58. package/types/components/SidebarLockButton.d.ts +8 -0
  59. package/types/components/SingleLibraryItem.d.ts +0 -1
  60. package/types/components/Spinner.d.ts +0 -1
  61. package/types/components/Stack.d.ts +1 -1
  62. package/types/components/Toast.d.ts +4 -3
  63. package/types/constants.d.ts +3 -1
  64. package/types/data/blob.d.ts +4 -4
  65. package/types/data/filesystem.d.ts +2 -2
  66. package/types/data/json.d.ts +1 -1
  67. package/types/element/Hyperlink.d.ts +8 -3
  68. package/types/element/binding.d.ts +3 -3
  69. package/types/element/dragElements.d.ts +1 -1
  70. package/types/element/linearElementEditor.d.ts +7 -2
  71. package/types/element/mutateElement.d.ts +1 -1
  72. package/types/element/textElement.d.ts +1 -1
  73. package/types/element/typeChecks.d.ts +3 -3
  74. package/types/jotai.d.ts +5 -3
  75. package/types/keys.d.ts +1 -1
  76. package/types/packages/excalidraw/example/App.d.ts +0 -1
  77. package/types/renderer/renderElement.d.ts +1 -1
  78. package/types/renderer/renderScene.d.ts +9 -1
  79. package/types/shapes.d.ts +0 -1
  80. package/types/types.d.ts +21 -12
  81. package/types/utils.d.ts +8 -5
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ #### Note
2
+
3
+ ⚠️ ⚠️ ⚠️ You are viewing the docs for the **next** release, in case you want to check the docs for the stable release, you can view it [here](https://www.npmjs.com/package/@excalidraw/excalidraw).
4
+
1
5
  ### Excalidraw
2
6
 
3
7
  Excalidraw exported as a component to directly embed in your projects.
@@ -26,7 +30,7 @@ If you want to load assets from a different path you can set a variable `window.
26
30
 
27
31
  #### Note
28
32
 
29
- **If you don't want to wait for the next stable release and try out the unreleased changes you can use [@excalidraw/excalidraw-next](https://www.npmjs.com/package/@excalidraw/excalidraw-next).**
33
+ **If you don't want to wait for the next stable release and try out the unreleased changes you can use `@excalidraw/excalidraw@next`.**
30
34
 
31
35
  ### Demo
32
36
 
@@ -42,7 +46,7 @@ If you are using a Web bundler (for instance, Webpack), you can import it as an
42
46
 
43
47
  ```js
44
48
  import React, { useEffect, useState, useRef } from "react";
45
- import Excalidraw from "@excalidraw/excalidraw";
49
+ import { Excalidraw } from "@excalidraw/excalidraw";
46
50
  import InitialData from "./initialData";
47
51
 
48
52
  import "./styles.scss";
@@ -322,7 +326,7 @@ const App = () => {
322
326
  className: "excalidraw-wrapper",
323
327
  ref: excalidrawWrapperRef,
324
328
  },
325
- React.createElement(Excalidraw.default, {
329
+ React.createElement(ExcalidrawLib.Excalidraw, {
326
330
  initialData: InitialData,
327
331
  onChange: (elements, state) =>
328
332
  console.log("Elements :", elements, "State : ", state),
@@ -377,7 +381,7 @@ For a complete list of variables, check [theme.scss](https://github.com/excalidr
377
381
  | Name | Type | Default | Description |
378
382
  | --- | --- | --- | --- |
379
383
  | [`onChange`](#onChange) | Function | | This callback is triggered whenever the component updates due to any change. This callback will receive the excalidraw elements and the current app state. |
380
- | [`initialData`](#initialData) | <pre>{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> } </pre> | null | The initial data with which app loads. |
384
+ | [`initialData`](#initialData) | <pre>{elements?: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement[]</a>, appState?: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState<a> } </pre> | null | The initial data with which app loads. |
381
385
  | [`ref`](#ref) | [`createRef`](https://reactjs.org/docs/refs-and-the-dom.html#creating-refs) &#124; [`useRef`](https://reactjs.org/docs/hooks-reference.html#useref) &#124; [`callbackRef`](https://reactjs.org/docs/refs-and-the-dom.html#callback-refs) &#124; <pre>{ current: { readyPromise: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/utils.ts#L317">resolvablePromise</a> } }</pre> | | Ref to be passed to Excalidraw |
382
386
  | [`onCollabButtonClick`](#onCollabButtonClick) | Function | | Callback to be triggered when the collab button is clicked |
383
387
  | [`isCollaborating`](#isCollaborating) | `boolean` | | This implies if the app is in collaboration mode |
@@ -399,7 +403,9 @@ For a complete list of variables, check [theme.scss](https://github.com/excalidr
399
403
  | [`onLibraryChange`](#onLibraryChange) | <pre>(items: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200">LibraryItems</a>) => void &#124; Promise&lt;any&gt; </pre> | | The callback if supplied is triggered when the library is updated and receives the library items. |
400
404
  | [`autoFocus`](#autoFocus) | boolean | false | Implies whether to focus the Excalidraw component on page load |
401
405
  | [`generateIdForFile`](#generateIdForFile) | `(file: File) => string | Promise<string>` | Allows you to override `id` generation for files added on canvas |
402
- | [`onLinkOpen`](#onLinkOpen) | <pre>(element: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">NonDeletedExcalidrawElement</a>, event: CustomEvent) </pre> | | This prop if passed will be triggered when link of an element is clicked |
406
+ | [`onLinkOpen`](#onLinkOpen) | <pre>(element: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">NonDeletedExcalidrawElement</a>, event: CustomEvent) </pre> | | This prop if passed will be triggered when link of an element is clicked. |
407
+ | [`onPointerDown`](#onPointerDown) | <pre>(activeTool: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L93"> AppState["activeTool"]</a>, pointerDownState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L365">PointerDownState</a>) => void</pre> | | This prop if passed gets triggered on pointer down evenets |
408
+ | [`onScrollChange`](#onScrollChange) | (scrollX: number, scrollY: number) | | This prop if passed gets triggered when scrolling the canvas. |
403
409
 
404
410
  ### Dimensions of Excalidraw
405
411
 
@@ -413,9 +419,9 @@ Every time component updates, this callback if passed will get triggered and has
413
419
  (excalidrawElements, appState, files) => void;
414
420
  ```
415
421
 
416
- 1.`excalidrawElements`: Array of [excalidrawElements](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78) in the scene.
422
+ 1.`excalidrawElements`: Array of [excalidrawElements](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106) in the scene.
417
423
 
418
- 2.`appState`: [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42) of the scene.
424
+ 2.`appState`: [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79) of the scene.
419
425
 
420
426
  3. `files`: The [`BinaryFiles`]([BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64) which are added to the scene.
421
427
 
@@ -427,10 +433,10 @@ This helps to load Excalidraw with `initialData`. It must be an object or a [pro
427
433
 
428
434
  | Name | Type | Description |
429
435
  | --- | --- | --- |
430
- | `elements` | [ExcalidrawElement[]](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78) | The elements with which Excalidraw should be mounted. |
431
- | `appState` | [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42) | The App state with which Excalidraw should be mounted. |
436
+ | `elements` | [ExcalidrawElement[]](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106) | The elements with which Excalidraw should be mounted. |
437
+ | `appState` | [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79) | The App state with which Excalidraw should be mounted. |
432
438
  | `scrollToContent` | boolean | This attribute implies whether to scroll to the nearest element to center once Excalidraw is mounted. By default, it will not scroll the nearest element to the center. Make sure you pass `initialData.appState.scrollX` and `initialData.appState.scrollY` when `scrollToContent` is false so that scroll positions are retained |
433
- | `libraryItems` | [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L151) | This library items with which Excalidraw should be mounted. |
439
+ | `libraryItems` | [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200) &#124; Promise<[LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200)> | This library items with which Excalidraw should be mounted. |
434
440
  | `files` | [BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64) | The files added to the scene. |
435
441
 
436
442
  ```json
@@ -469,23 +475,27 @@ You might want to use this when you want to load excalidraw with some initial el
469
475
  You can pass a `ref` when you want to access some excalidraw APIs. We expose the below APIs:
470
476
 
471
477
  | API | signature | Usage |
472
- | --- | --- | --- |
478
+ | --- | --- | --- | --- |
473
479
  | ready | `boolean` | This is set to true once Excalidraw is rendered |
474
480
  | readyPromise | [resolvablePromise](https://github.com/excalidraw/excalidraw/blob/master/src/utils.ts#L317) | This promise will be resolved with the api once excalidraw has rendered. This will be helpful when you want do some action on the host app once this promise resolves. For this to work you will have to pass ref as shown [here](#readyPromise) |
475
- | [updateScene](#updateScene) | <pre>(scene: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L207">sceneData</a>) => void </pre> | updates the scene with the sceneData |
476
- | [addFiles](#addFiles) | <pre>(files: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts">BinaryFileData</a>) => void </pre> | add files data to the appState |
481
+ | [updateScene](#updateScene) | <code>(scene: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L207">sceneData</a>) => void </code> | updates the scene with the sceneData |
482
+ | [updateLibrary](#updateLibrary) | <code>(<a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/library.ts#L136">opts</a>) => Promise<<a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200">LibraryItems</a>> </code> | updates the scene with the sceneData |
483
+ | [addFiles](#addFiles) | <code>(files: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts">BinaryFileData</a>) => void </code> | add files data to the appState |
477
484
  | resetScene | `({ resetLoadingState: boolean }) => void` | Resets the scene. If `resetLoadingState` is passed as true then it will also force set the loading state to false. |
478
- | getSceneElementsIncludingDeleted | <pre> () => <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement[]</a></pre> | Returns all the elements including the deleted in the scene |
479
- | getSceneElements | <pre> () => <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement[]</a></pre> | Returns all the elements excluding the deleted in the scene |
480
- | getAppState | <pre> () => <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a></pre> | Returns current appState |
485
+ | getSceneElementsIncludingDeleted | <code> () => <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement[]</a></code> | Returns all the elements including the deleted in the scene |
486
+ | getSceneElements | <code> () => <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement[]</a></code> | Returns all the elements excluding the deleted in the scene |
487
+ | getAppState | <code> () => <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L66">AppState</a></code> | Returns current appState |
481
488
  | history | `{ clear: () => void }` | This is the history API. `history.clear()` will clear the history |
482
- | scrollToContent | <pre> (target?: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement</a> &#124; <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement</a>[]) => void </pre> | Scroll the nearest element out of the elements supplied to the center. Defaults to the elements on the scene. |
489
+ | scrollToContent | <code> (target?: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement</a> &#124; <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement</a>[]) => void </code> | Scroll the nearest element out of the elements supplied to the center. Defaults to the elements on the scene. |
483
490
  | zoomToFit | `(target?:ExcalidrawElement[], maxZoom:number=1, margin:number=0.03) => void` | Zoom to fit elements on viewport. If no elements are supplied, the function will zoom to fit all elements. `maxZoom` is the maximum zoom level allowed (default 100%). `margin` is understood in % of viewport width and height. Default value is a minimum of 1.5% margin around the image compared to viewport . |
484
491
  | refresh | `() => void` | Updates the offsets for the Excalidraw component so that the coordinates are computed correctly (for example the cursor position). You don't have to call this when the position is changed on page scroll or when the excalidraw container resizes (we handle that ourselves). For any other cases if the position of excalidraw is updated (example due to scroll on parent container and not page scroll) you should call this API. |
485
492
  | [importLibrary](#importlibrary) | `(url: string, token?: string) => void` | Imports library from given URL |
486
- | setToastMessage | `(message: string) => void` | This API can be used to show the toast with custom message. |
493
+ | [setToast](#setToast) | `({message: string, closable?:boolean, duration?:number} | null) => void` | This API can be used to show the toast with custom message. |
487
494
  | [id](#id) | string | Unique ID for the excalidraw component. |
488
- | [getFiles](#getFiles) | <pre>() => <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64">files</a> </pre> | This API can be used to get the files present in the scene. It may contain files that aren't referenced by any element, so if you're persisting the files to a storage, you should compare them against stored elements. |
495
+ | [getFiles](#getFiles) | <code>() => <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64">files</a> </code> | This API can be used to get the files present in the scene. It may contain files that aren't referenced by any element, so if you're persisting the files to a storage, you should compare them against stored elements. |
496
+ | [setActiveTool](#setActiveTool) | <code>(tool: { type: typeof <a href="https://github.com/excalidraw/excalidraw/blob/master/src/shapes.tsx#L4">SHAPES</a>[number]["value"] &#124; "eraser" } &#124; { type: "custom"; customType: string }) => void</code> | This API can be used to set the active tool |
497
+ | [setCursor](#setCursor) | <code>(cursor: string) => void </code> | This API can be used to set customise the mouse cursor on the canvas |
498
+ | [resetCursor](#resetCursor) | <code>() => void </code> | This API can be used to reset to default mouse cursor on the canvas |
489
499
 
490
500
  #### `readyPromise`
491
501
 
@@ -507,9 +517,31 @@ You can use this function to update the scene with the sceneData. It accepts the
507
517
  | --- | --- | --- |
508
518
  | `elements` | [`ImportedDataState["elements"]`](https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L17) | The `elements` to be updated in the scene |
509
519
  | `appState` | [`ImportedDataState["appState"]`](https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L18) | The `appState` to be updated in the scene. |
510
- | `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. |
520
+ | `collaborators` | <pre>Map<string, <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L35">Collaborator></a></pre> | The list of collaborators to be updated in the scene. |
511
521
  | `commitToHistory` | `boolean` | Implies if the `history (undo/redo)` should be recorded. Defaults to `false`. |
512
- | `libraryItems` | [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L258) | The `libraryItems` to be update in the scene. |
522
+ | `libraryItems` | [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200) &#124; Promise<[LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200)> &#124; ((currentItems: [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200)>) => [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200) &#124; Promise<[LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200)>) | The `libraryItems` to be update in the scene. |
523
+
524
+ ### `updateLibrary`
525
+
526
+ <pre>
527
+ (opts: {
528
+ libraryItems: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L224">LibraryItemsSource</a>;
529
+ merge?: boolean;
530
+ prompt?: boolean;
531
+ openLibraryMenu?: boolean;
532
+ defaultStatus?: "unpublished" | "published";
533
+ }) => Promise<<a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200">LibraryItems</a>>
534
+ </pre>
535
+
536
+ You can use this function to update the library. It accepts the below attributes.
537
+
538
+ | Name | Type | Default | Description |
539
+ | --- | --- | --- | --- |
540
+ | `libraryItems` | | [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L224) | The `libraryItems` to be replaced/merged with current library |
541
+ | `merge` | boolean | `false` | Whether to merge with existing library items. |
542
+ | `prompt` | boolean | `false` | Whether to prompt user for confirmation. |
543
+ | `openLibraryMenu` | boolean | `false` | Whether to open the library menu before importing. |
544
+ | `defaultStatus` | <code>"unpublished" &#124; "published"</code> | `"unpublished"` | Default library item's `status` if not present. |
513
545
 
514
546
  ### `addFiles`
515
547
 
@@ -544,7 +576,7 @@ This callback is triggered when mouse pointer is updated.
544
576
  ```
545
577
 
546
578
  1. `exportedElements`: An array of [non deleted elements](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L87) which needs to be exported.
547
- 2. `appState`: [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42) of the scene.
579
+ 2. `appState`: [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79) of the scene.
548
580
  3. `canvas`: The `HTMLCanvasElement` of the scene.
549
581
 
550
582
  #### `langCode`
@@ -563,7 +595,7 @@ import { defaultLang, languages } from "@excalidraw/excalidraw";
563
595
  #### `renderTopRightUI`
564
596
 
565
597
  <pre>
566
- (isMobile: boolean, appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a>) => JSX
598
+ (isMobile: boolean, appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a>) => JSX | null
567
599
  </pre>
568
600
 
569
601
  A function returning JSX to render custom UI in the top right corner of the app.
@@ -571,7 +603,7 @@ A function returning JSX to render custom UI in the top right corner of the app.
571
603
  #### `renderFooter`
572
604
 
573
605
  <pre>
574
- (isMobile: boolean, appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a>) => JSX
606
+ (isMobile: boolean, appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a>) => JSX | null
575
607
  </pre>
576
608
 
577
609
  A function returning JSX to render custom UI footer. For example, you can use this to render a language picker that was previously being rendered by Excalidraw itself (for now, you'll need to implement your own language picker).
@@ -606,7 +638,7 @@ This prop sets the name of the drawing which will be used when exporting the dra
606
638
 
607
639
  #### `UIOptions`
608
640
 
609
- This prop can be used to customise UI of Excalidraw. Currently we support customising only [`canvasActions`](#canvasActions). It accepts the below parameters
641
+ This prop can be used to customise UI of Excalidraw. Currently we support customising [`canvasActions`](#canvasActions) and [`dockedSidebarBreakpoint`](dockedSidebarBreakpoint). It accepts the below parameters
610
642
 
611
643
  <pre>
612
644
  { canvasActions: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L208"> CanvasActions<a/> }
@@ -624,6 +656,12 @@ This prop can be used to customise UI of Excalidraw. Currently we support custom
624
656
  | `theme` | boolean | true | Implies whether to show `Theme toggle` |
625
657
  | `saveAsImage` | boolean | true | Implies whether to show `Save as image button` |
626
658
 
659
+ ##### `dockedSidebarBreakpoint`
660
+
661
+ This prop indicates at what point should we break to a docked, permanent sidebar. If not passed it defaults to [`MQ_RIGHT_SIDEBAR_MAX_WIDTH_PORTRAIT`](https://github.com/excalidraw/excalidraw/blob/master/src/constants.ts#L167). If the `width` of the `excalidraw` container exceeds `dockedSidebarBreakpoint`, the sidebar will be dockable. If user choses to dock the sidebar, it will push the right part of the UI towards the left, making space for the sidebar as shown below.
662
+
663
+ ![image](https://user-images.githubusercontent.com/11256141/174664866-c698c3fa-197b-43ff-956c-d79852c7b326.png)
664
+
627
665
  #### `exportOpts`
628
666
 
629
667
  The below attributes can be set in `UIOptions.canvasActions.export` to customize the export dialog. If `UIOptions.canvasActions.export` is `false` the export button will not be rendered.
@@ -668,6 +706,48 @@ useEffect(() => {
668
706
 
669
707
  Try out the [Demo](#Demo) to see it in action.
670
708
 
709
+ #### `setToast`
710
+
711
+ This API can be used to show the toast with custom message.
712
+
713
+ <pre>
714
+ ({ message: string,
715
+ closable?:boolean,
716
+ duration?:number } | null) => void
717
+ </pre>
718
+
719
+ | Attribute | type | Description |
720
+ | --- | --- | --- |
721
+ | message | string | The message to be shown on the toast. |
722
+ | closable | boolean | Indicates whether to show the closable button on toast to dismiss the toast. |
723
+ | duration | number | Determines the duration after which the toast should auto dismiss. To prevent autodimiss you can pass `Infinity`. |
724
+
725
+ To dismiss an existing toast you can simple pass `null`
726
+
727
+ ```js
728
+ setToast(null);
729
+ ```
730
+
731
+ #### `setActiveTool`
732
+
733
+ This API has the below signature. It sets the `tool` passed in param as the active tool.
734
+
735
+ <pre>
736
+ (tool: { type: typeof <a href="https://github.com/excalidraw/excalidraw/blob/master/src/shapes.tsx#L4">SHAPES</a>[number]["value"] &#124; "eraser" } &#124; { type: "custom"; customType: string }) => void
737
+ </pre>
738
+
739
+ #### `setCursor`
740
+
741
+ This API can be used to customise the mouse cursor on the canvas and has the below signature. It sets the mouse cursor to the cursor passed in param.
742
+
743
+ <pre>
744
+ (cursor: string) => void
745
+ </pre>
746
+
747
+ #### `resetCursor`
748
+
749
+ This API can be used to reset to default mouse cursor.
750
+
671
751
  #### `detectScroll`
672
752
 
673
753
  Indicates whether Excalidraw should listen for `scroll` event on the nearest scrollable container in the DOM tree and recompute the coordinates (e.g. to correctly handle the cursor) when the component's position changes. You can disable this when you either know this doesn't affect your app or you want to take care of it yourself (calling the [`refresh()`](#ref) method).
@@ -737,6 +817,22 @@ const onLinkOpen: ExcalidrawProps["onLinkOpen"] = useCallback(
737
817
  );
738
818
  ```
739
819
 
820
+ #### `onPointerDown`
821
+
822
+ This prop if passed will be triggered on pointer down events and has the below signature.
823
+
824
+ <pre>
825
+ (activeTool: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L93"> AppState["activeTool"]</a>, pointerDownState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L365">PointerDownState</a>) => void
826
+ </pre>
827
+
828
+ #### `onScrollChange`
829
+
830
+ This prop if passed will be triggered when canvas is scrolled and has the below signature.
831
+
832
+ ```ts
833
+ (scrollX: number, scrollY: number) => void
834
+ ```
835
+
740
836
  ### Does it support collaboration ?
741
837
 
742
838
  No, Excalidraw package doesn't come with collaboration built in, since the implementation is specific to each host app. We expose APIs which you can use to communicate with Excalidraw which you can use to implement it. You can check our own implementation [here](https://github.com/excalidraw/excalidraw/blob/master/src/excalidraw-app/index.tsx).
@@ -748,7 +844,7 @@ No, Excalidraw package doesn't come with collaboration built in, since the imple
748
844
  **_Signature_**
749
845
 
750
846
  <pre>
751
- restoreAppState(appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L17">ImportedDataState["appState"]</a>, localAppState: Partial<<a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a>> | null): <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a>
847
+ restoreAppState(appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L17">ImportedDataState["appState"]</a>, localAppState: Partial<<a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a>> | null): <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a>
752
848
  </pre>
753
849
 
754
850
  **_How to use_**
@@ -757,7 +853,7 @@ restoreAppState(appState: <a href="https://github.com/excalidraw/excalidraw/blob
757
853
  import { restoreAppState } from "@excalidraw/excalidraw";
758
854
  ```
759
855
 
760
- This function will make sure all the keys have appropriate values in [appState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42) and if any key is missing, it will be set to default value.
856
+ This function will make sure all the keys have appropriate values in [appState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79) and if any key is missing, it will be set to default value.
761
857
 
762
858
  When `localAppState` is supplied, it's used in place of values that are missing (`undefined`) in `appState` instead of defaults. Use this as a way to not override user's defaults if you persist them. Required: supply `null`/`undefined` if not applicable.
763
859
 
@@ -766,7 +862,7 @@ When `localAppState` is supplied, it's used in place of values that are missing
766
862
  **_Signature_**
767
863
 
768
864
  <pre>
769
- restoreElements(elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L16">ImportedDataState["elements"]</a>, localElements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L16">ExcalidrawElement[]</a> | null | undefined): <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement[]</a>
865
+ restoreElements(elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L16">ImportedDataState["elements"]</a>, localElements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L16">ExcalidrawElement[]</a> | null | undefined): <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement[]</a>
770
866
  </pre>
771
867
 
772
868
  **_How to use_**
@@ -784,7 +880,7 @@ When `localElements` are supplied, they are used to ensure that existing restore
784
880
  **_Signature_**
785
881
 
786
882
  <pre>
787
- restoreElements(data: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L12">ImportedDataState</a>, localAppState: Partial<<a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a>> | null | undefined, localElements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L16">ExcalidrawElement[]</a> | null | undefined): <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L4">DataState</a>
883
+ restoreElements(data: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L12">ImportedDataState</a>, localAppState: Partial<<a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a>> | null | undefined, localElements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L16">ExcalidrawElement[]</a> | null | undefined): <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L4">DataState</a>
788
884
  </pre>
789
885
 
790
886
  See [`restoreAppState()`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#restoreAppState) about `localAppState`, and [`restoreElements()`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#restoreElements) about `localElements`.
@@ -797,6 +893,24 @@ import { restore } from "@excalidraw/excalidraw";
797
893
 
798
894
  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).
799
895
 
896
+ #### `restoreLibraryItems`
897
+
898
+ **_Signature_**
899
+
900
+ <pre>
901
+ restoreLibraryItems(libraryItems: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L22">ImportedDataState["libraryItems"]</a>, defaultStatus: "published" | "unpublished")
902
+ </pre>
903
+
904
+ **_How to use_**
905
+
906
+ ```js
907
+ import { restoreLibraryItems } from "@excalidraw/excalidraw";
908
+
909
+ restoreLibraryItems(libraryItems, "unpublished");
910
+ ```
911
+
912
+ This function normalizes library items elements, adding missing values when needed.
913
+
800
914
  ### Export utilities
801
915
 
802
916
  #### `exportToCanvas`
@@ -834,7 +948,7 @@ This function returns the canvas with the exported elements, appState and dimens
834
948
 
835
949
  <pre>
836
950
  exportToBlob(
837
- opts: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/packages/utils.ts#L10">ExportOpts</a> & {
951
+ opts: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/packages/utils.ts#L14">ExportOpts</a> & {
838
952
  mimeType?: string,
839
953
  quality?: number;
840
954
  })
@@ -860,8 +974,8 @@ Returns a promise which resolves with a [blob](https://developer.mozilla.org/en-
860
974
 
861
975
  <pre>
862
976
  exportToSvg({
863
- elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement[]</a>,
864
- appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a>,
977
+ elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement[]</a>,
978
+ appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a>,
865
979
  exportPadding?: number,
866
980
  metadata?: string,
867
981
  files?: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64">BinaryFiles</a>
@@ -870,13 +984,41 @@ exportToSvg({
870
984
 
871
985
  | Name | Type | Default | Description |
872
986
  | --- | --- | --- | --- |
873
- | elements | [Excalidraw Element []](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78) | | The elements to exported as svg |
874
- | appState | [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42) | [defaultAppState](https://github.com/excalidraw/excalidraw/blob/master/src/appState.ts#L11) | The app state of the scene |
987
+ | elements | [Excalidraw Element []](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106) | | The elements to exported as svg |
988
+ | appState | [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79) | [defaultAppState](https://github.com/excalidraw/excalidraw/blob/master/src/appState.ts#L11) | The app state of the scene |
875
989
  | exportPadding | number | 10 | The padding to be added on canvas |
876
990
  | files | [BinaryFiles](The [`BinaryFiles`](<[BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64)>) | undefined | The files added to the scene. |
877
991
 
878
992
  This function returns a promise which resolves to svg of the exported drawing.
879
993
 
994
+ #### `exportToClipboard`
995
+
996
+ **_Signature_**
997
+
998
+ <pre>
999
+ exportToClipboard(
1000
+ opts: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/packages/utils.ts#L14">ExportOpts</a> & {
1001
+ mimeType?: string,
1002
+ quality?: number;
1003
+ type: 'png' | 'svg' |'json'
1004
+ })
1005
+ </pre>
1006
+
1007
+ | Name | Type | Default | Description |
1008
+ | --- | --- | --- | --- | --- | --- |
1009
+ | opts | | | This param is same as the params passed to `exportToCanvas`. You can refer to [`exportToCanvas`](#exportToCanvas). |
1010
+ | mimeType | string | "image/png" | Indicates the image format, this will be used when exporting as `png`. |
1011
+ | quality | number | 0.92 | A value between 0 and 1 indicating the [image quality](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#parameters). Applies only to `image/jpeg`/`image/webp` MIME types. This will be used when exporting as `png`. |
1012
+ | type | 'png' | 'svg' | 'json' | | This determines the format to which the scene data should be exported. |
1013
+
1014
+ **How to use**
1015
+
1016
+ ```js
1017
+ import { exportToClipboard } from "@excalidraw/excalidraw";
1018
+ ```
1019
+
1020
+ Copies the scene data in the specified format (determined by `type`) to clipboard.
1021
+
880
1022
  ##### Additional attributes of appState for `export\*` APIs
881
1023
 
882
1024
  | Name | Type | Default | Description |
@@ -884,7 +1026,7 @@ This function returns a promise which resolves to svg of the exported drawing.
884
1026
  | exportBackground | boolean | true | Indicates whether background should be exported |
885
1027
  | viewBackgroundColor | string | #fff | The default background color |
886
1028
  | exportWithDarkMode | boolean | false | Indicates whether to export with dark mode |
887
- | exportEmbedScene | boolean | false | Indicates whether scene data should be embedded in svg. This will increase the svg size. |
1029
+ | exportEmbedScene | boolean | false | Indicates whether scene data should be embedded in svg/png. This will increase the image size. |
888
1030
 
889
1031
  ### Extra API's
890
1032
 
@@ -894,20 +1036,35 @@ This function returns a promise which resolves to svg of the exported drawing.
894
1036
 
895
1037
  <pre>
896
1038
  serializeAsJSON({
897
- elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement[]</a>,
898
- appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a>,
1039
+ elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement[]</a>,
1040
+ appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a>,
899
1041
  }): string
900
1042
  </pre>
901
1043
 
902
1044
  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).
903
1045
 
1046
+ If you want to overwrite the source field in the JSON string, you can set `window.EXCALIDRAW_EXPORT_SOURCE` to the desired value.
1047
+
1048
+ #### `serializeLibraryAsJSON`
1049
+
1050
+ **_Signature_**
1051
+
1052
+ <pre>
1053
+ serializeLibraryAsJSON({
1054
+ libraryItems: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200">LibraryItems[]</a>,
1055
+ </pre>
1056
+
1057
+ Takes the library items and returns a JSON string.
1058
+
1059
+ If you want to overwrite the source field in the JSON string, you can set `window.EXCALIDRAW_EXPORT_SOURCE` to the desired value.
1060
+
904
1061
  #### `getSceneVersion`
905
1062
 
906
1063
  **How to use**
907
1064
 
908
1065
  <pre>
909
1066
  import { getSceneVersion } from "@excalidraw/excalidraw";
910
- getSceneVersion(elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement[]</a>)
1067
+ getSceneVersion(elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement[]</a>)
911
1068
  </pre>
912
1069
 
913
1070
  This function returns the current scene version.
@@ -917,7 +1074,7 @@ This function returns the current scene version.
917
1074
  **_Signature_**
918
1075
 
919
1076
  <pre>
920
- isInvisiblySmallElement(element: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement</a>): boolean
1077
+ isInvisiblySmallElement(element: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement</a>): boolean
921
1078
  </pre>
922
1079
 
923
1080
  **How to use**
@@ -948,15 +1105,51 @@ This function loads the library from the blob.
948
1105
 
949
1106
  ```js
950
1107
  import { loadFromBlob } from "@excalidraw/excalidraw";
1108
+
1109
+ const scene = await loadFromBlob(file, null, null);
1110
+ excalidrawAPI.updateScene(scene);
951
1111
  ```
952
1112
 
953
1113
  **Signature**
954
1114
 
955
1115
  <pre>
956
- 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)
1116
+ loadFromBlob(
1117
+ blob: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob">Blob</a>,
1118
+ localAppState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a> | null,
1119
+ localElements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement[]</a> | null,
1120
+ fileHandle?: FileSystemHandle | null
1121
+ ) => Promise<<a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/restore.ts#L53">RestoredDataState</a>>
957
1122
  </pre>
958
1123
 
959
- This function loads the scene data from the blob. If you pass `localAppState`, `localAppState` value will be preferred over the `appState` derived from `blob`
1124
+ This function loads the scene data from the blob (or file). If you pass `localAppState`, `localAppState` value will be preferred over the `appState` derived from `blob`. Throws if blob doesn't contain valid scene data.
1125
+
1126
+ #### `loadSceneOrLibraryFromBlob`
1127
+
1128
+ **How to use**
1129
+
1130
+ ```js
1131
+ import { loadSceneOrLibraryFromBlob, MIME_TYPES } from "@excalidraw/excalidraw";
1132
+
1133
+ const contents = await loadSceneOrLibraryFromBlob(file, null, null);
1134
+ if (contents.type === MIME_TYPES.excalidraw) {
1135
+ excalidrawAPI.updateScene(contents.data);
1136
+ } else if (contents.type === MIME_TYPES.excalidrawlib) {
1137
+ excalidrawAPI.updateLibrary(contents.data);
1138
+ }
1139
+ ```
1140
+
1141
+ **Signature**
1142
+
1143
+ <pre>
1144
+ loadSceneOrLibraryFromBlob(
1145
+ blob: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob">Blob</a>,
1146
+ localAppState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a> | null,
1147
+ localElements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement[]</a> | null,
1148
+ fileHandle?: FileSystemHandle | null
1149
+ ) => Promise<{ type: string, data: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/restore.ts#L53">RestoredDataState</a> | <a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L33">ImportedLibraryState</a>}>
1150
+ </pre>
1151
+
1152
+ This function loads either scene or library data from the supplied blob. If the blob contains scene data, and you pass `localAppState`, `localAppState` value will be preferred over the `appState` derived from `blob`. Throws if blob doesn't contain neither valid scene data or library data.
960
1153
 
961
1154
  #### `getFreeDrawSvgPath`
962
1155
 
@@ -1006,6 +1199,93 @@ getNonDeletedElements(elements: <a href="https://github.com/excalidraw/excalidra
1006
1199
 
1007
1200
  This function returns an array of deleted elements.
1008
1201
 
1202
+ #### `mergeLibraryItems`
1203
+
1204
+ ```js
1205
+ import { mergeLibraryItems } from "@excalidraw/excalidraw";
1206
+ ```
1207
+
1208
+ **_Signature_**
1209
+
1210
+ <pre>
1211
+ mergeLibraryItems(localItems: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200">LibraryItems</a>, otherItems: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200">LibraryItems</a>) => <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200">LibraryItems</a>
1212
+ </pre>
1213
+
1214
+ This function merges two `LibraryItems` arrays, where unique items from `otherItems` are sorted first in the returned array.
1215
+
1216
+ #### `parseLibraryTokensFromUrl`
1217
+
1218
+ **How to use**
1219
+
1220
+ ```js
1221
+ import { parseLibraryTokensFromUrl } from "@excalidraw/excalidraw";
1222
+ ```
1223
+
1224
+ **Signature**
1225
+
1226
+ <pre>
1227
+ parseLibraryTokensFromUrl(): {
1228
+ libraryUrl: string;
1229
+ idToken: string | null;
1230
+ } | null
1231
+ </pre>
1232
+
1233
+ Parses library parameters from URL if present (expects the `#addLibrary` hash key), and returns an object with the `libraryUrl` and `idToken`. Returns `null` if `#addLibrary` hash key not found.
1234
+
1235
+ #### `useHandleLibrary`
1236
+
1237
+ **How to use**
1238
+
1239
+ ```js
1240
+ import { useHandleLibrary } from "@excalidraw/excalidraw";
1241
+
1242
+ export const App = () => {
1243
+ // ...
1244
+ useHandleLibrary({ excalidrawAPI });
1245
+ };
1246
+ ```
1247
+
1248
+ **Signature**
1249
+
1250
+ <pre>
1251
+ useHandleLibrary(opts: {
1252
+ excalidrawAPI: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L432">ExcalidrawAPI</a>,
1253
+ getInitialLibraryItems?: () => <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L224">LibraryItemsSource</a>
1254
+ });
1255
+ </pre>
1256
+
1257
+ A hook that automatically imports library from url if `#addLibrary` hash key exists on initial load, or when it changes during the editing session (e.g. when a user installs a new library), and handles initial library load if `getInitialLibraryItems` getter is supplied.
1258
+
1259
+ In the future, we will be adding support for handling library persistence to browser storage (or elsewhere).
1260
+
1261
+ #### `sceneCoordsToViewportCoords`
1262
+
1263
+ ```js
1264
+ import { sceneCoordsToViewportCoords } from "@excalidraw/excalidraw";
1265
+ ```
1266
+
1267
+ **_Signature_**
1268
+
1269
+ <pre>
1270
+ sceneCoordsToViewportCoords({sceneX: number, sceneY: number}, appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a>): {x: number, y: number}
1271
+ </pre>
1272
+
1273
+ This function returns equivalent viewport coords for the provided scene coords in params.
1274
+
1275
+ #### `viewportCoordsToSceneCoords`
1276
+
1277
+ ```js
1278
+ import { viewportCoordsToSceneCoords } from "@excalidraw/excalidraw";
1279
+ ```
1280
+
1281
+ **_Signature_**
1282
+
1283
+ <pre>
1284
+ viewportCoordsToSceneCoords({clientX: number, clientY: number}, appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a>): {x: number, y: number}
1285
+ </pre>
1286
+
1287
+ This function returns equivalent scene coords for the provided viewport coords in params.
1288
+
1009
1289
  ### Exported constants
1010
1290
 
1011
1291
  #### `FONT_FAMILY`
@@ -1043,6 +1323,16 @@ import { THEME } from "@excalidraw/excalidraw";
1043
1323
 
1044
1324
  Defaults to `THEME.LIGHT` unless passed in `initialData.appState.theme`
1045
1325
 
1326
+ ### `MIME_TYPES`
1327
+
1328
+ **How to use **
1329
+
1330
+ ```js
1331
+ import { MIME_TYPES } from "@excalidraw/excalidraw";
1332
+ ```
1333
+
1334
+ [`MIME_TYPES`](https://github.com/excalidraw/excalidraw/blob/master/src/constants.ts#L92) contains all the mime types supported by `Excalidraw`.
1335
+
1046
1336
  ## Need help?
1047
1337
 
1048
1338
  Check out the existing [Q&A](https://github.com/excalidraw/excalidraw/discussions?discussions_q=label%3Apackage%3Aexcalidraw). If you have any queries or need help, ask us [here](https://github.com/excalidraw/excalidraw/discussions?discussions_q=label%3Apackage%3Aexcalidraw).
@@ -1070,7 +1360,27 @@ The example is same as the [codesandbox example](https://ehlz3.csb.app/)
1070
1360
  You can create a test release by posting the below comment in your pull request
1071
1361
 
1072
1362
  ```
1073
- @excalibot release package
1363
+ @excalibot trigger release
1074
1364
  ```
1075
1365
 
1076
1366
  Once the version is released `@excalibot` will post a comment with the release version.
1367
+
1368
+ #### Creating a production release
1369
+
1370
+ To release the next stable version follow the below steps
1371
+
1372
+ ```
1373
+ yarn prerelease version
1374
+ ```
1375
+
1376
+ You need to pass the `version` for which you want to create the release. This will make the changes needed before making the release like updating `package.json`, `changelog` and more.
1377
+
1378
+ The next step is to run the `release` script
1379
+
1380
+ ```
1381
+ yarn release
1382
+ ```
1383
+
1384
+ This will publish the package.
1385
+
1386
+ Right now there are two steps to create a production release but once this works fine these scripts will be combined and more automation will be done.