@dwelle/excalidraw 0.3.63 → 0.3.66
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.
- package/CHANGELOG.md +28 -0
- package/README_NEXT.md +246 -35
- package/dist/excalidraw.development.js +52 -52
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +8 -8
- package/types/actions/actionAddToLibrary.d.ts +21 -3
- package/types/actions/actionBoundText.d.ts +7 -1
- package/types/actions/actionCanvas.d.ts +57 -9
- package/types/actions/actionClipboard.d.ts +36 -6
- package/types/actions/actionDeleteSelected.d.ts +22 -4
- package/types/actions/actionDuplicateSelection.d.ts +1 -1
- package/types/actions/actionExport.d.ts +64 -10
- package/types/actions/actionFinalize.d.ts +18 -5
- package/types/actions/actionMenu.d.ts +21 -3
- package/types/actions/actionProperties.d.ts +91 -13
- package/types/actions/actionStyles.d.ts +7 -1
- package/types/actions/actionToggleGridMode.d.ts +7 -1
- package/types/actions/actionToggleStats.d.ts +7 -1
- package/types/actions/actionToggleViewMode.d.ts +7 -1
- package/types/actions/actionToggleZenMode.d.ts +7 -1
- package/types/appState.d.ts +8 -2
- package/types/charts.d.ts +8 -0
- package/types/clipboard.d.ts +1 -1
- package/types/components/App.d.ts +9 -3
- package/types/components/Avatar.d.ts +3 -2
- package/types/components/LibraryMenu.d.ts +3 -3
- package/types/components/LibraryMenuItems.d.ts +5 -4
- package/types/components/LibraryUnit.d.ts +2 -1
- package/types/constants.d.ts +3 -0
- package/types/data/blob.d.ts +21 -1
- package/types/data/json.d.ts +0 -2
- package/types/data/library.d.ts +50 -51
- package/types/data/types.d.ts +2 -2
- package/types/distribute.d.ts +6 -0
- package/types/element/Hyperlink.d.ts +7 -1
- package/types/element/linearElementEditor.d.ts +11 -2
- package/types/packages/excalidraw/dist/excalidraw.production.min.d.ts +1 -3
- package/types/packages/excalidraw/index.d.ts +5 -5
- package/types/packages/utils.d.ts +7 -3
- package/types/scene/Scene.d.ts +1 -2
- package/types/types.d.ts +23 -5
- package/types/utils.d.ts +10 -1
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,34 @@ Please add the latest change on the top under the correct section.
|
|
|
17
17
|
|
|
18
18
|
#### Features
|
|
19
19
|
|
|
20
|
+
- Export [`sceneCoordsToViewportCoords`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#onPointerDown) and [`viewportCoordsToSceneCoords`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#onPointerDown) utilities [#5187](https://github.com/excalidraw/excalidraw/pull/5187).
|
|
21
|
+
|
|
22
|
+
- Added [`useHandleLibrary`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#useHandleLibrary) hook to automatically handle importing of libraries when `#addLibrary` URL hash key is present, and potentially for initializing library as well [#5115](https://github.com/excalidraw/excalidraw/pull/5115).
|
|
23
|
+
|
|
24
|
+
Also added [`parseLibraryTokensFromUrl`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#parseLibraryTokensFromUrl) to help in manually importing library from URL if desired.
|
|
25
|
+
|
|
26
|
+
##### BREAKING CHANGE
|
|
27
|
+
|
|
28
|
+
- Libraries are no longer automatically initialized from URL when `#addLibrary` hash key is present. Host apps now need to handle this themselves with the help of either of the above APIs (`useHandleLibrary` is recommended).
|
|
29
|
+
|
|
30
|
+
- Added [`updateLibrary`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#updateLibrary) API to update (replace/merge) the library [#5115](https://github.com/excalidraw/excalidraw/pull/5115).
|
|
31
|
+
|
|
32
|
+
##### BREAKING CHANGE
|
|
33
|
+
|
|
34
|
+
- `updateScene` API no longer supports passing `libraryItems`. Instead, use the `updateLibrary` API.
|
|
35
|
+
|
|
36
|
+
- Add support for integrating custom elements [#5164](https://github.com/excalidraw/excalidraw/pull/5164).
|
|
37
|
+
|
|
38
|
+
- Add [`onPointerDown`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#onPointerDown) callback which gets triggered on pointer down events.
|
|
39
|
+
- Add [`onScrollChange`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#onScrollChange) callback which gets triggered when scrolling the canvas.
|
|
40
|
+
- Add API [`setActiveTool`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#setActiveTool) which host can call to set the active tool.
|
|
41
|
+
|
|
42
|
+
- Exported [`loadSceneOrLibraryFromBlob`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#loadSceneOrLibraryFromBlob) function [#5057](https://github.com/excalidraw/excalidraw/pull/5057).
|
|
43
|
+
- Export [`MIME_TYPES`](https://github.com/excalidraw/excalidraw/blob/master/src/constants.ts#L92) supported by Excalidraw [#5135](https://github.com/excalidraw/excalidraw/pull/5135).
|
|
44
|
+
- Support [`avatarUrl`](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L50) for collaborators. Now onwards host can pass `avatarUrl` to render the customized avatar for collaborators [#5114](https://github.com/excalidraw/excalidraw/pull/5114), renamed in [#5177](https://github.com/excalidraw/excalidraw/pull/5177).
|
|
45
|
+
- Support `libraryItems` argument in `initialData.libraryItems` and `updateScene({ libraryItems })` to be a Promise resolving to `LibraryItems`, and support functional update of `libraryItems` in [`updateScene({ libraryItems })`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#updateScene). [#5101](https://github.com/excalidraw/excalidraw/pull/5101).
|
|
46
|
+
- Expose util [`mergeLibraryItems`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#mergeLibraryItems) [#5101](https://github.com/excalidraw/excalidraw/pull/5101).
|
|
47
|
+
- Expose util [`exportToClipboard`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#exportToClipboard) which allows to copy the scene contents to clipboard as `svg`, `png` or `json` [#5103](https://github.com/excalidraw/excalidraw/pull/5103).
|
|
20
48
|
- Expose `window.EXCALIDRAW_EXPORT_SOURCE` which you can use to overwrite the `source` field in exported data [#5095](https://github.com/excalidraw/excalidraw/pull/5095).
|
|
21
49
|
- The `exportToBlob` utility now supports the `exportEmbedScene` option when generating a png image [#5047](https://github.com/excalidraw/excalidraw/pull/5047).
|
|
22
50
|
- Exported [`restoreLibraryItems`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#restoreLibraryItems) API [#4995](https://github.com/excalidraw/excalidraw/pull/4995).
|
package/README_NEXT.md
CHANGED
|
@@ -383,7 +383,7 @@ For a complete list of variables, check [theme.scss](https://github.com/excalidr
|
|
|
383
383
|
| Name | Type | Default | Description |
|
|
384
384
|
| --- | --- | --- | --- |
|
|
385
385
|
| [`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. |
|
|
386
|
-
| [`initialData`](#initialData) | <pre>{elements?: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#
|
|
386
|
+
| [`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. |
|
|
387
387
|
| [`ref`](#ref) | [`createRef`](https://reactjs.org/docs/refs-and-the-dom.html#creating-refs) | [`useRef`](https://reactjs.org/docs/hooks-reference.html#useref) | [`callbackRef`](https://reactjs.org/docs/refs-and-the-dom.html#callback-refs) | <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 |
|
|
388
388
|
| [`onCollabButtonClick`](#onCollabButtonClick) | Function | | Callback to be triggered when the collab button is clicked |
|
|
389
389
|
| [`isCollaborating`](#isCollaborating) | `boolean` | | This implies if the app is in collaboration mode |
|
|
@@ -405,7 +405,9 @@ For a complete list of variables, check [theme.scss](https://github.com/excalidr
|
|
|
405
405
|
| [`onLibraryChange`](#onLibraryChange) | <pre>(items: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200">LibraryItems</a>) => void | Promise<any> </pre> | | The callback if supplied is triggered when the library is updated and receives the library items. |
|
|
406
406
|
| [`autoFocus`](#autoFocus) | boolean | false | Implies whether to focus the Excalidraw component on page load |
|
|
407
407
|
| [`generateIdForFile`](#generateIdForFile) | `(file: File) => string | Promise<string>` | Allows you to override `id` generation for files added on canvas |
|
|
408
|
-
| [`onLinkOpen`](#onLinkOpen) | <pre>(element: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#
|
|
408
|
+
| [`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. |
|
|
409
|
+
| [`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 |
|
|
410
|
+
| [`onScrollChange`](#onScrollChange) | (scrollX: number, scrollY: number) | | This prop if passed gets triggered when scrolling the canvas. |
|
|
409
411
|
|
|
410
412
|
### Dimensions of Excalidraw
|
|
411
413
|
|
|
@@ -419,9 +421,9 @@ Every time component updates, this callback if passed will get triggered and has
|
|
|
419
421
|
(excalidrawElements, appState, files) => void;
|
|
420
422
|
```
|
|
421
423
|
|
|
422
|
-
1.`excalidrawElements`: Array of [excalidrawElements](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#
|
|
424
|
+
1.`excalidrawElements`: Array of [excalidrawElements](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106) in the scene.
|
|
423
425
|
|
|
424
|
-
2.`appState`: [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#
|
|
426
|
+
2.`appState`: [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79) of the scene.
|
|
425
427
|
|
|
426
428
|
3. `files`: The [`BinaryFiles`]([BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64) which are added to the scene.
|
|
427
429
|
|
|
@@ -433,10 +435,10 @@ This helps to load Excalidraw with `initialData`. It must be an object or a [pro
|
|
|
433
435
|
|
|
434
436
|
| Name | Type | Description |
|
|
435
437
|
| --- | --- | --- |
|
|
436
|
-
| `elements` | [ExcalidrawElement[]](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#
|
|
437
|
-
| `appState` | [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#
|
|
438
|
+
| `elements` | [ExcalidrawElement[]](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106) | The elements with which Excalidraw should be mounted. |
|
|
439
|
+
| `appState` | [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79) | The App state with which Excalidraw should be mounted. |
|
|
438
440
|
| `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 |
|
|
439
|
-
| `libraryItems` | [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#
|
|
441
|
+
| `libraryItems` | [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200) | Promise<[LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200)> | This library items with which Excalidraw should be mounted. |
|
|
440
442
|
| `files` | [BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64) | The files added to the scene. |
|
|
441
443
|
|
|
442
444
|
```json
|
|
@@ -478,19 +480,21 @@ You can pass a `ref` when you want to access some excalidraw APIs. We expose the
|
|
|
478
480
|
| --- | --- | --- |
|
|
479
481
|
| ready | `boolean` | This is set to true once Excalidraw is rendered |
|
|
480
482
|
| 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) |
|
|
481
|
-
| [updateScene](#updateScene) | <
|
|
482
|
-
| [
|
|
483
|
+
| [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 |
|
|
484
|
+
| [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 |
|
|
485
|
+
| [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 |
|
|
483
486
|
| resetScene | `({ resetLoadingState: boolean }) => void` | Resets the scene. If `resetLoadingState` is passed as true then it will also force set the loading state to false. |
|
|
484
|
-
| getSceneElementsIncludingDeleted | <
|
|
485
|
-
| getSceneElements | <
|
|
486
|
-
| getAppState | <
|
|
487
|
+
| 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 |
|
|
488
|
+
| 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 |
|
|
489
|
+
| getAppState | <code> () => <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L66">AppState</a></code> | Returns current appState |
|
|
487
490
|
| history | `{ clear: () => void }` | This is the history API. `history.clear()` will clear the history |
|
|
488
|
-
| scrollToContent | <
|
|
491
|
+
| scrollToContent | <code> (target?: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement</a> | <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. |
|
|
489
492
|
| 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. |
|
|
490
493
|
| [importLibrary](#importlibrary) | `(url: string, token?: string) => void` | Imports library from given URL |
|
|
491
494
|
| setToastMessage | `(message: string) => void` | This API can be used to show the toast with custom message. |
|
|
492
495
|
| [id](#id) | string | Unique ID for the excalidraw component. |
|
|
493
|
-
| [getFiles](#getFiles) | <
|
|
496
|
+
| [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. |
|
|
497
|
+
| [setActiveTool](#setActiveTool) | <code>(tool: { type: typeof <a href="https://github.com/excalidraw/excalidraw/blob/master/src/shapes.tsx#L4">SHAPES</a>[number]["value"] | "eraser" } | { type: "custom"; customType: string }) => void</code> | This API can be used to set the active tool |
|
|
494
498
|
|
|
495
499
|
#### `readyPromise`
|
|
496
500
|
|
|
@@ -512,9 +516,31 @@ You can use this function to update the scene with the sceneData. It accepts the
|
|
|
512
516
|
| --- | --- | --- |
|
|
513
517
|
| `elements` | [`ImportedDataState["elements"]`](https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L17) | The `elements` to be updated in the scene |
|
|
514
518
|
| `appState` | [`ImportedDataState["appState"]`](https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L18) | The `appState` to be updated in the scene. |
|
|
515
|
-
| `collaborators` | <pre>Map<string, <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#
|
|
519
|
+
| `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. |
|
|
516
520
|
| `commitToHistory` | `boolean` | Implies if the `history (undo/redo)` should be recorded. Defaults to `false`. |
|
|
517
|
-
| `libraryItems` | [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#
|
|
521
|
+
| `libraryItems` | [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200) | Promise<[LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200)> | ((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) | Promise<[LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200)>) | The `libraryItems` to be update in the scene. |
|
|
522
|
+
|
|
523
|
+
### `updateLibrary`
|
|
524
|
+
|
|
525
|
+
<pre>
|
|
526
|
+
(opts: {
|
|
527
|
+
libraryItems: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L224">LibraryItemsSource</a>;
|
|
528
|
+
merge?: boolean;
|
|
529
|
+
prompt?: boolean;
|
|
530
|
+
openLibraryMenu?: boolean;
|
|
531
|
+
defaultStatus?: "unpublished" | "published";
|
|
532
|
+
}) => Promise<<a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200">LibraryItems</a>>
|
|
533
|
+
</pre>
|
|
534
|
+
|
|
535
|
+
You can use this function to update the library. It accepts the below attributes.
|
|
536
|
+
|
|
537
|
+
| Name | Type | Default | Description |
|
|
538
|
+
| --- | --- | --- | --- |
|
|
539
|
+
| `libraryItems` | | [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L224) | The `libraryItems` to be replaced/merged with current library |
|
|
540
|
+
| `merge` | boolean | `false` | Whether to merge with existing library items. |
|
|
541
|
+
| `prompt` | boolean | `false` | Whether to prompt user for confirmation. |
|
|
542
|
+
| `openLibraryMenu` | boolean | `false` | Whether to open the library menu before importing. |
|
|
543
|
+
| `defaultStatus` | <code>"unpublished" | "published"</code> | `"unpublished"` | Default library item's `status` if not present. |
|
|
518
544
|
|
|
519
545
|
### `addFiles`
|
|
520
546
|
|
|
@@ -549,7 +575,7 @@ This callback is triggered when mouse pointer is updated.
|
|
|
549
575
|
```
|
|
550
576
|
|
|
551
577
|
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.
|
|
552
|
-
2. `appState`: [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#
|
|
578
|
+
2. `appState`: [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79) of the scene.
|
|
553
579
|
3. `canvas`: The `HTMLCanvasElement` of the scene.
|
|
554
580
|
|
|
555
581
|
#### `langCode`
|
|
@@ -568,7 +594,7 @@ import { defaultLang, languages } from "@excalidraw/excalidraw-next";
|
|
|
568
594
|
#### `renderTopRightUI`
|
|
569
595
|
|
|
570
596
|
<pre>
|
|
571
|
-
(isMobile: boolean, appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#
|
|
597
|
+
(isMobile: boolean, appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a>) => JSX
|
|
572
598
|
</pre>
|
|
573
599
|
|
|
574
600
|
A function returning JSX to render custom UI in the top right corner of the app.
|
|
@@ -576,7 +602,7 @@ A function returning JSX to render custom UI in the top right corner of the app.
|
|
|
576
602
|
#### `renderFooter`
|
|
577
603
|
|
|
578
604
|
<pre>
|
|
579
|
-
(isMobile: boolean, appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#
|
|
605
|
+
(isMobile: boolean, appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a>) => JSX
|
|
580
606
|
</pre>
|
|
581
607
|
|
|
582
608
|
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).
|
|
@@ -673,6 +699,14 @@ useEffect(() => {
|
|
|
673
699
|
|
|
674
700
|
Try out the [Demo](#Demo) to see it in action.
|
|
675
701
|
|
|
702
|
+
#### `setActiveTool`
|
|
703
|
+
|
|
704
|
+
This API has the below signature. It sets the `tool` passed in param as the active tool.
|
|
705
|
+
|
|
706
|
+
<pre>
|
|
707
|
+
(tool: { type: typeof <a href="https://github.com/excalidraw/excalidraw/blob/master/src/shapes.tsx#L4">SHAPES</a>[number]["value"] | "eraser" } | { type: "custom"; customType: string }) => void
|
|
708
|
+
</pre>
|
|
709
|
+
|
|
676
710
|
#### `detectScroll`
|
|
677
711
|
|
|
678
712
|
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).
|
|
@@ -742,6 +776,22 @@ const onLinkOpen: ExcalidrawProps["onLinkOpen"] = useCallback(
|
|
|
742
776
|
);
|
|
743
777
|
```
|
|
744
778
|
|
|
779
|
+
#### `onPointerDown`
|
|
780
|
+
|
|
781
|
+
This prop if passed will be triggered on pointer down events and has the below signature.
|
|
782
|
+
|
|
783
|
+
<pre>
|
|
784
|
+
(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
|
|
785
|
+
</pre>
|
|
786
|
+
|
|
787
|
+
#### `onScrollChange`
|
|
788
|
+
|
|
789
|
+
This prop if passed will be triggered when canvas is scrolled and has the below signature.
|
|
790
|
+
|
|
791
|
+
```ts
|
|
792
|
+
(scrollX: number, scrollY: number) => void
|
|
793
|
+
```
|
|
794
|
+
|
|
745
795
|
### Does it support collaboration ?
|
|
746
796
|
|
|
747
797
|
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).
|
|
@@ -753,7 +803,7 @@ No, Excalidraw package doesn't come with collaboration built in, since the imple
|
|
|
753
803
|
**_Signature_**
|
|
754
804
|
|
|
755
805
|
<pre>
|
|
756
|
-
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#
|
|
806
|
+
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>
|
|
757
807
|
</pre>
|
|
758
808
|
|
|
759
809
|
**_How to use_**
|
|
@@ -762,7 +812,7 @@ restoreAppState(appState: <a href="https://github.com/excalidraw/excalidraw/blob
|
|
|
762
812
|
import { restoreAppState } from "@excalidraw/excalidraw-next";
|
|
763
813
|
```
|
|
764
814
|
|
|
765
|
-
This function will make sure all the keys have appropriate values in [appState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#
|
|
815
|
+
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.
|
|
766
816
|
|
|
767
817
|
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.
|
|
768
818
|
|
|
@@ -771,7 +821,7 @@ When `localAppState` is supplied, it's used in place of values that are missing
|
|
|
771
821
|
**_Signature_**
|
|
772
822
|
|
|
773
823
|
<pre>
|
|
774
|
-
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#
|
|
824
|
+
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>
|
|
775
825
|
</pre>
|
|
776
826
|
|
|
777
827
|
**_How to use_**
|
|
@@ -789,7 +839,7 @@ When `localElements` are supplied, they are used to ensure that existing restore
|
|
|
789
839
|
**_Signature_**
|
|
790
840
|
|
|
791
841
|
<pre>
|
|
792
|
-
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#
|
|
842
|
+
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>
|
|
793
843
|
</pre>
|
|
794
844
|
|
|
795
845
|
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`.
|
|
@@ -857,7 +907,7 @@ This function returns the canvas with the exported elements, appState and dimens
|
|
|
857
907
|
|
|
858
908
|
<pre>
|
|
859
909
|
exportToBlob(
|
|
860
|
-
opts: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/packages/utils.ts#
|
|
910
|
+
opts: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/packages/utils.ts#L14">ExportOpts</a> & {
|
|
861
911
|
mimeType?: string,
|
|
862
912
|
quality?: number;
|
|
863
913
|
})
|
|
@@ -883,8 +933,8 @@ Returns a promise which resolves with a [blob](https://developer.mozilla.org/en-
|
|
|
883
933
|
|
|
884
934
|
<pre>
|
|
885
935
|
exportToSvg({
|
|
886
|
-
elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#
|
|
887
|
-
appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#
|
|
936
|
+
elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement[]</a>,
|
|
937
|
+
appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a>,
|
|
888
938
|
exportPadding?: number,
|
|
889
939
|
metadata?: string,
|
|
890
940
|
files?: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64">BinaryFiles</a>
|
|
@@ -893,13 +943,41 @@ exportToSvg({
|
|
|
893
943
|
|
|
894
944
|
| Name | Type | Default | Description |
|
|
895
945
|
| --- | --- | --- | --- |
|
|
896
|
-
| elements | [Excalidraw Element []](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#
|
|
897
|
-
| appState | [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#
|
|
946
|
+
| elements | [Excalidraw Element []](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106) | | The elements to exported as svg |
|
|
947
|
+
| 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 |
|
|
898
948
|
| exportPadding | number | 10 | The padding to be added on canvas |
|
|
899
949
|
| files | [BinaryFiles](The [`BinaryFiles`](<[BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64)>) | undefined | The files added to the scene. |
|
|
900
950
|
|
|
901
951
|
This function returns a promise which resolves to svg of the exported drawing.
|
|
902
952
|
|
|
953
|
+
#### `exportToClipboard`
|
|
954
|
+
|
|
955
|
+
**_Signature_**
|
|
956
|
+
|
|
957
|
+
<pre>
|
|
958
|
+
exportToClipboard(
|
|
959
|
+
opts: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/packages/utils.ts#L14">ExportOpts</a> & {
|
|
960
|
+
mimeType?: string,
|
|
961
|
+
quality?: number;
|
|
962
|
+
type: 'png' | 'svg' |'json'
|
|
963
|
+
})
|
|
964
|
+
</pre>
|
|
965
|
+
|
|
966
|
+
| Name | Type | Default | Description |
|
|
967
|
+
| --- | --- | --- | --- | --- | --- |
|
|
968
|
+
| opts | | | This param is same as the params passed to `exportToCanvas`. You can refer to [`exportToCanvas`](#exportToCanvas). |
|
|
969
|
+
| mimeType | string | "image/png" | Indicates the image format, this will be used when exporting as `png`. |
|
|
970
|
+
| 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`. |
|
|
971
|
+
| type | 'png' | 'svg' | 'json' | | This determines the format to which the scene data should be exported. |
|
|
972
|
+
|
|
973
|
+
**How to use**
|
|
974
|
+
|
|
975
|
+
```js
|
|
976
|
+
import { exportToClipboard } from "@excalidraw/excalidraw-next";
|
|
977
|
+
```
|
|
978
|
+
|
|
979
|
+
Copies the scene data in the specified format (determined by `type`) to clipboard.
|
|
980
|
+
|
|
903
981
|
##### Additional attributes of appState for `export\*` APIs
|
|
904
982
|
|
|
905
983
|
| Name | Type | Default | Description |
|
|
@@ -917,8 +995,8 @@ This function returns a promise which resolves to svg of the exported drawing.
|
|
|
917
995
|
|
|
918
996
|
<pre>
|
|
919
997
|
serializeAsJSON({
|
|
920
|
-
elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#
|
|
921
|
-
appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#
|
|
998
|
+
elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement[]</a>,
|
|
999
|
+
appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a>,
|
|
922
1000
|
}): string
|
|
923
1001
|
</pre>
|
|
924
1002
|
|
|
@@ -932,7 +1010,7 @@ If you want to overwrite the source field in the JSON string, you can set `windo
|
|
|
932
1010
|
|
|
933
1011
|
<pre>
|
|
934
1012
|
serializeLibraryAsJSON({
|
|
935
|
-
libraryItems: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#
|
|
1013
|
+
libraryItems: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200">LibraryItems[]</a>,
|
|
936
1014
|
</pre>
|
|
937
1015
|
|
|
938
1016
|
Takes the library items and returns a JSON string.
|
|
@@ -945,7 +1023,7 @@ If you want to overwrite the source field in the JSON string, you can set `windo
|
|
|
945
1023
|
|
|
946
1024
|
<pre>
|
|
947
1025
|
import { getSceneVersion } from "@excalidraw/excalidraw-next";
|
|
948
|
-
getSceneVersion(elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#
|
|
1026
|
+
getSceneVersion(elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement[]</a>)
|
|
949
1027
|
</pre>
|
|
950
1028
|
|
|
951
1029
|
This function returns the current scene version.
|
|
@@ -955,7 +1033,7 @@ This function returns the current scene version.
|
|
|
955
1033
|
**_Signature_**
|
|
956
1034
|
|
|
957
1035
|
<pre>
|
|
958
|
-
isInvisiblySmallElement(element: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#
|
|
1036
|
+
isInvisiblySmallElement(element: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement</a>): boolean
|
|
959
1037
|
</pre>
|
|
960
1038
|
|
|
961
1039
|
**How to use**
|
|
@@ -986,15 +1064,51 @@ This function loads the library from the blob.
|
|
|
986
1064
|
|
|
987
1065
|
```js
|
|
988
1066
|
import { loadFromBlob } from "@excalidraw/excalidraw-next";
|
|
1067
|
+
|
|
1068
|
+
const scene = await loadFromBlob(file, null, null);
|
|
1069
|
+
excalidrawAPI.updateScene(scene);
|
|
989
1070
|
```
|
|
990
1071
|
|
|
991
1072
|
**Signature**
|
|
992
1073
|
|
|
993
1074
|
<pre>
|
|
994
|
-
loadFromBlob(
|
|
1075
|
+
loadFromBlob(
|
|
1076
|
+
blob: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob">Blob</a>,
|
|
1077
|
+
localAppState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a> | null,
|
|
1078
|
+
localElements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement[]</a> | null,
|
|
1079
|
+
fileHandle?: FileSystemHandle | null
|
|
1080
|
+
) => Promise<<a href="https://github.com/excalidraw/excalidraw/blob/master/src/data/restore.ts#L53">RestoredDataState</a>>
|
|
995
1081
|
</pre>
|
|
996
1082
|
|
|
997
|
-
This function loads the scene data from the blob. If you pass `localAppState`, `localAppState` value will be preferred over the `appState` derived from `blob
|
|
1083
|
+
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.
|
|
1084
|
+
|
|
1085
|
+
#### `loadSceneOrLibraryFromBlob`
|
|
1086
|
+
|
|
1087
|
+
**How to use**
|
|
1088
|
+
|
|
1089
|
+
```js
|
|
1090
|
+
import { loadSceneOrLibraryFromBlob, MIME_TYPES } from "@excalidraw/excalidraw";
|
|
1091
|
+
|
|
1092
|
+
const contents = await loadSceneOrLibraryFromBlob(file, null, null);
|
|
1093
|
+
if (contents.type === MIME_TYPES.excalidraw) {
|
|
1094
|
+
excalidrawAPI.updateScene(contents.data);
|
|
1095
|
+
} else if (contents.type === MIME_TYPES.excalidrawlib) {
|
|
1096
|
+
excalidrawAPI.updateLibrary(contents.data);
|
|
1097
|
+
}
|
|
1098
|
+
```
|
|
1099
|
+
|
|
1100
|
+
**Signature**
|
|
1101
|
+
|
|
1102
|
+
<pre>
|
|
1103
|
+
loadSceneOrLibraryFromBlob(
|
|
1104
|
+
blob: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob">Blob</a>,
|
|
1105
|
+
localAppState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a> | null,
|
|
1106
|
+
localElements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">ExcalidrawElement[]</a> | null,
|
|
1107
|
+
fileHandle?: FileSystemHandle | null
|
|
1108
|
+
) => 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>}>
|
|
1109
|
+
</pre>
|
|
1110
|
+
|
|
1111
|
+
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.
|
|
998
1112
|
|
|
999
1113
|
#### `getFreeDrawSvgPath`
|
|
1000
1114
|
|
|
@@ -1044,6 +1158,93 @@ getNonDeletedElements(elements: <a href="https://github.com/excalidraw/excalidra
|
|
|
1044
1158
|
|
|
1045
1159
|
This function returns an array of deleted elements.
|
|
1046
1160
|
|
|
1161
|
+
#### `mergeLibraryItems`
|
|
1162
|
+
|
|
1163
|
+
```js
|
|
1164
|
+
import { mergeLibraryItems } from "@excalidraw/excalidraw-next";
|
|
1165
|
+
```
|
|
1166
|
+
|
|
1167
|
+
**_Signature_**
|
|
1168
|
+
|
|
1169
|
+
<pre>
|
|
1170
|
+
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>
|
|
1171
|
+
</pre>
|
|
1172
|
+
|
|
1173
|
+
This function merges two `LibraryItems` arrays, where unique items from `otherItems` are sorted first in the returned array.
|
|
1174
|
+
|
|
1175
|
+
#### `parseLibraryTokensFromUrl`
|
|
1176
|
+
|
|
1177
|
+
**How to use**
|
|
1178
|
+
|
|
1179
|
+
```js
|
|
1180
|
+
import { parseLibraryTokensFromUrl } from "@excalidraw/excalidraw-next";
|
|
1181
|
+
```
|
|
1182
|
+
|
|
1183
|
+
**Signature**
|
|
1184
|
+
|
|
1185
|
+
<pre>
|
|
1186
|
+
parseLibraryTokensFromUrl(): {
|
|
1187
|
+
libraryUrl: string;
|
|
1188
|
+
idToken: string | null;
|
|
1189
|
+
} | null
|
|
1190
|
+
</pre>
|
|
1191
|
+
|
|
1192
|
+
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.
|
|
1193
|
+
|
|
1194
|
+
#### `useHandleLibrary`
|
|
1195
|
+
|
|
1196
|
+
**How to use**
|
|
1197
|
+
|
|
1198
|
+
```js
|
|
1199
|
+
import { useHandleLibrary } from "@excalidraw/excalidraw-next";
|
|
1200
|
+
|
|
1201
|
+
export const App = () => {
|
|
1202
|
+
// ...
|
|
1203
|
+
useHandleLibrary({ excalidrawAPI });
|
|
1204
|
+
};
|
|
1205
|
+
```
|
|
1206
|
+
|
|
1207
|
+
**Signature**
|
|
1208
|
+
|
|
1209
|
+
<pre>
|
|
1210
|
+
useHandleLibrary(opts: {
|
|
1211
|
+
excalidrawAPI: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L432">ExcalidrawAPI</a>,
|
|
1212
|
+
getInitialLibraryItems?: () => <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L224">LibraryItemsSource</a>
|
|
1213
|
+
});
|
|
1214
|
+
</pre>
|
|
1215
|
+
|
|
1216
|
+
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.
|
|
1217
|
+
|
|
1218
|
+
In the future, we will be adding support for handling library persistence to browser storage (or elsewhere).
|
|
1219
|
+
|
|
1220
|
+
#### `sceneCoordsToViewportCoords`
|
|
1221
|
+
|
|
1222
|
+
```js
|
|
1223
|
+
import { sceneCoordsToViewportCoords } from "@excalidraw/excalidraw-next";
|
|
1224
|
+
```
|
|
1225
|
+
|
|
1226
|
+
**_Signature_**
|
|
1227
|
+
|
|
1228
|
+
<pre>
|
|
1229
|
+
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}
|
|
1230
|
+
</pre>
|
|
1231
|
+
|
|
1232
|
+
This function returns equivalent viewport coords for the provided scene coords in params.
|
|
1233
|
+
|
|
1234
|
+
#### `viewportCoordsToSceneCoords`
|
|
1235
|
+
|
|
1236
|
+
```js
|
|
1237
|
+
import { viewportCoordsToSceneCoords } from "@excalidraw/excalidraw-next";
|
|
1238
|
+
```
|
|
1239
|
+
|
|
1240
|
+
**_Signature_**
|
|
1241
|
+
|
|
1242
|
+
<pre>
|
|
1243
|
+
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}
|
|
1244
|
+
</pre>
|
|
1245
|
+
|
|
1246
|
+
This function returns equivalent scene coords for the provided viewport coords in params.
|
|
1247
|
+
|
|
1047
1248
|
### Exported constants
|
|
1048
1249
|
|
|
1049
1250
|
#### `FONT_FAMILY`
|
|
@@ -1081,6 +1282,16 @@ import { THEME } from "@excalidraw/excalidraw-next";
|
|
|
1081
1282
|
|
|
1082
1283
|
Defaults to `THEME.LIGHT` unless passed in `initialData.appState.theme`
|
|
1083
1284
|
|
|
1285
|
+
### `MIME_TYPES`
|
|
1286
|
+
|
|
1287
|
+
**How to use **
|
|
1288
|
+
|
|
1289
|
+
```js
|
|
1290
|
+
import { MIME_TYPES } from "@excalidraw/excalidraw-next";
|
|
1291
|
+
```
|
|
1292
|
+
|
|
1293
|
+
[`MIME_TYPES`](https://github.com/excalidraw/excalidraw/blob/master/src/constants.ts#L92) contains all the mime types supported by `Excalidraw`.
|
|
1294
|
+
|
|
1084
1295
|
## Need help?
|
|
1085
1296
|
|
|
1086
1297
|
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).
|