@dwelle/excalidraw 0.3.43 → 0.3.47

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/README.md CHANGED
@@ -347,6 +347,31 @@ To view the full example visit :point_down:
347
347
 
348
348
  </details>
349
349
 
350
+ ### Customizing styles
351
+
352
+ Excalidraw is using CSS variables to style certain components. To override them, you should set your own on the `.excalidraw` and `.excalidraw.theme--dark` (for dark mode variables) selectors.
353
+
354
+ Make sure the selector has higher specificity, e.g. by prefixing it with your app's selector:
355
+
356
+ ```css
357
+ .your-app .excalidraw {
358
+ --color-primary: red;
359
+ }
360
+ .your-app .excalidraw.theme--dark {
361
+ --color-primary: pink;
362
+ }
363
+ ```
364
+
365
+ Most notably, you can customize the primary colors, by overriding these variables:
366
+
367
+ - `--color-primary`
368
+ - `--color-primary-darker`
369
+ - `--color-primary-darkest`
370
+ - `--color-primary-light`
371
+ - `--color-primary-contrast-offset` — a slightly darker (in light mode), or lighter (in dark mode) `--color-primary` color to fix contrast issues (see [Chubb illusion](https://en.wikipedia.org/wiki/Chubb_illusion)). It will fall back to `--color-primary` if not present.
372
+
373
+ For a complete list of variables, check [theme.scss](https://github.com/excalidraw/excalidraw/blob/master/src/css/theme.scss), though most of them will not make sense to override.
374
+
350
375
  ### Props
351
376
 
352
377
  | Name | Type | Default | Description |
@@ -365,14 +390,16 @@ To view the full example visit :point_down:
365
390
  | [`zenModeEnabled`](#zenModeEnabled) | boolean | | This implies if the zen mode is enabled |
366
391
  | [`gridModeEnabled`](#gridModeEnabled) | boolean | | This implies if the grid mode is enabled |
367
392
  | [`libraryReturnUrl`](#libraryReturnUrl) | string | | What URL should [libraries.excalidraw.com](https://libraries.excalidraw.com) be installed to |
368
- | [`theme`](#theme) | `light` or `dark` | | The theme of the Excalidraw component |
393
+ | [`theme`](#theme) | [THEME.LIGHT](#THEME-1) &#124; [THEME.LIGHT](#THEME-1) | [THEME.LIGHT](#THEME-1) | The theme of the Excalidraw component |
369
394
  | [`name`](#name) | string | | Name of the drawing |
370
395
  | [`UIOptions`](#UIOptions) | <pre>{ canvasActions: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L208"> CanvasActions<a/> }</pre> | [DEFAULT UI OPTIONS](https://github.com/excalidraw/excalidraw/blob/master/src/constants.ts#L129) | To customise UI options. Currently we support customising [`canvas actions`](#canvasActions) |
371
- | [`onPaste`](#onPaste) | <pre>(data: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/clipboard.ts#L17">ClipboardData</a>, event: ClipboardEvent &#124; null) => boolean</pre> | | Callback to be triggered if passed when the something is pasted in to the scene |
396
+ | [`onPaste`](#onPaste) | <pre>(data: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/clipboard.ts#L21">ClipboardData</a>, event: ClipboardEvent &#124; null) => boolean</pre> | | Callback to be triggered if passed when the something is pasted in to the scene |
372
397
  | [`detectScroll`](#detectScroll) | boolean | true | Indicates whether to update the offsets when nearest ancestor is scrolled. |
373
398
  | [`handleKeyboardGlobally`](#handleKeyboardGlobally) | boolean | false | Indicates whether to bind the keyboard events to document. |
374
399
  | [`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. |
375
400
  | [`autoFocus`](#autoFocus) | boolean | false | Implies whether to focus the Excalidraw component on page load |
401
+ | [`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 |
376
403
 
377
404
  ### Dimensions of Excalidraw
378
405
 
@@ -383,12 +410,14 @@ Excalidraw takes `100%` of `width` and `height` of the containing block so make
383
410
  Every time component updates, this callback if passed will get triggered and has the below signature.
384
411
 
385
412
  ```js
386
- (excalidrawElements, appState) => void;
413
+ (excalidrawElements, appState, files) => void;
387
414
  ```
388
415
 
389
416
  1.`excalidrawElements`: Array of [excalidrawElements](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78) in the scene.
390
417
 
391
- 2.`appState`: [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42) of the scene
418
+ 2.`appState`: [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42) of the scene.
419
+
420
+ 3. `files`: The [`BinaryFiles`]([BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64) which are added to the scene.
392
421
 
393
422
  Here you can try saving the data to your backend or local storage for example.
394
423
 
@@ -402,6 +431,7 @@ This helps to load Excalidraw with `initialData`. It must be an object or a [pro
402
431
  | `appState` | [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42) | The App state with which Excalidraw should be mounted. |
403
432
  | `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 |
404
433
  | `libraryItems` | [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L151) | This library items with which Excalidraw should be mounted. |
434
+ | `files` | [BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64) | The files added to the scene. |
405
435
 
406
436
  ```json
407
437
  {
@@ -442,7 +472,8 @@ You can pass a `ref` when you want to access some excalidraw APIs. We expose the
442
472
  | --- | --- | --- |
443
473
  | ready | `boolean` | This is set to true once Excalidraw is rendered |
444
474
  | 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) |
445
- | [updateScene](#updateScene) | <pre>(<a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L207">sceneData</a>)) => void </pre> | updates the scene with the sceneData |
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 |
446
477
  | resetScene | `({ resetLoadingState: boolean }) => void` | Resets the scene. If `resetLoadingState` is passed as true then it will also force set the loading state to false. |
447
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 |
448
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 |
@@ -453,6 +484,7 @@ You can pass a `ref` when you want to access some excalidraw APIs. We expose the
453
484
  | [importLibrary](#importlibrary) | `(url: string, token?: string) => void` | Imports library from given URL |
454
485
  | setToastMessage | `(message: string) => void` | This API can be used to show the toast with custom message. |
455
486
  | [id](#id) | string | Unique ID for the excalidraw component. |
487
+ | [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. |
456
488
 
457
489
  #### `readyPromise`
458
490
 
@@ -465,7 +497,7 @@ Since plain object is passed as a `ref`, the `readyPromise` is resolved as soon
465
497
  ### `updateScene`
466
498
 
467
499
  <pre>
468
- (<a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L207">sceneData</a>)) => void
500
+ (scene: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L207">sceneData</a>) => void
469
501
  </pre>
470
502
 
471
503
  You can use this function to update the scene with the sceneData. It accepts the below attributes.
@@ -476,6 +508,13 @@ You can use this function to update the scene with the sceneData. It accepts the
476
508
  | `appState` | [`ImportedDataState["appState"]`](https://github.com/excalidraw/excalidraw/blob/master/src/data/types.ts#L18) | The `appState` to be updated in the scene. |
477
509
  | `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. |
478
510
  | `commitToHistory` | `boolean` | Implies if the `history (undo/redo)` should be recorded. Defaults to `false`. |
511
+ | `libraryItems` | [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L258) | The `libraryItems` to be update in the scene. |
512
+
513
+ ### `addFiles`
514
+
515
+ <pre>(files: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts">BinaryFileData</a>) => void </pre>
516
+
517
+ Adds supplied files data to the `appState.files` cache on top of existing files present in the cache.
479
518
 
480
519
  #### `onCollabButtonClick`
481
520
 
@@ -558,7 +597,7 @@ If supplied, this URL will be used when user tries to install a library from [li
558
597
 
559
598
  #### `theme`
560
599
 
561
- This prop controls Excalidraw's theme. When supplied, the value takes precedence over `intialData.appState.theme`, the theme will be fully controlled by the host app, and users won't be able to toggle it from within the app.
600
+ This prop controls Excalidraw's theme. When supplied, the value takes precedence over `intialData.appState.theme`, the theme will be fully controlled by the host app, and users won't be able to toggle it from within the app. You can use [`THEME`](#THEME-1) to specify the theme.
562
601
 
563
602
  #### `name`
564
603
 
@@ -599,18 +638,14 @@ The below attributes can be set in `UIOptions.canvasActions.export` to customize
599
638
  This callback is triggered if passed when something is pasted into the scene. You can use this callback in case you want to do something additional when the paste event occurs.
600
639
 
601
640
  <pre>
602
- (data: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/clipboard.ts#L17">ClipboardData</a>, event: ClipboardEvent &#124; null) => boolean
641
+ (data: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/clipboard.ts#L21">ClipboardData</a>, event: ClipboardEvent &#124; null) => boolean
603
642
  </pre>
604
643
 
605
644
  This callback must return a `boolean` value or a [promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise) which resolves to a boolean value.
606
645
 
607
646
  In case you want to prevent the excalidraw paste action you must return `false`, it will stop the native excalidraw clipboard management flow (nothing will be pasted into the scene).
608
647
 
609
- ### Does it support collaboration ?
610
-
611
- 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).
612
-
613
- ### importLibrary
648
+ #### `importLibrary`
614
649
 
615
650
  Imports library from given URL. You should call this on `hashchange`, passing the `addLibrary` value if you detect it as shown below. Optionally pass a CSRF `token` to skip prompting during installation (retrievable via `token` key from the url coming from [https://libraries.excalidraw.com](https://libraries.excalidraw.com/)).
616
651
 
@@ -632,17 +667,17 @@ useEffect(() => {
632
667
 
633
668
  Try out the [Demo](#Demo) to see it in action.
634
669
 
635
- ### detectScroll
670
+ #### `detectScroll`
636
671
 
637
672
  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).
638
673
 
639
- ### handleKeyboardGlobally
674
+ #### `handleKeyboardGlobally`
640
675
 
641
676
  Indicates whether to bind keyboard events to `document`. Disabled by default, meaning the keyboard events are bound to the Excalidraw component. This allows for multiple Excalidraw components to live on the same page, and ensures that Excalidraw keyboard handling doesn't collide with your app's (or the browser) when the component isn't focused.
642
677
 
643
678
  Enable this if you want Excalidraw to handle keyboard even if the component isn't focused (e.g. a user is interacting with the navbar, sidebar, or similar).
644
679
 
645
- ### onLibraryChange
680
+ #### `onLibraryChange`
646
681
 
647
682
  Ths callback if supplied will get triggered when the library is updated and has the below signature.
648
683
 
@@ -652,58 +687,58 @@ Ths callback if supplied will get triggered when the library is updated and has
652
687
 
653
688
  It is invoked with empty items when user clears the library. You can use this callback when you want to do something additional when library is updated for example persisting it to local storage.
654
689
 
655
- ### id
690
+ #### `id`
656
691
 
657
692
  The unique id of the excalidraw component. This can be used to identify the excalidraw component, for example importing the library items to the excalidraw component from where it was initiated when you have multiple excalidraw components rendered on the same page as shown in [multiple excalidraw demo](https://codesandbox.io/s/multiple-excalidraw-k1xx5).
658
693
 
659
- ### autoFocus
694
+ #### `autoFocus`
660
695
 
661
696
  This prop implies whether to focus the Excalidraw component on page load. Defaults to false.
662
697
 
663
- ### Extra API's
664
-
665
- #### `getSceneVersion`
666
-
667
- **How to use**
668
-
669
- <pre>
670
- import { getSceneVersion } from "@excalidraw/excalidraw";
671
- getSceneVersion(elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement[]</a>)
672
- </pre>
673
-
674
- This function returns the current scene version.
675
-
676
- #### `isInvisiblySmallElement`
698
+ #### `generateIdForFile`
677
699
 
678
- **_Signature_**
700
+ Allows you to override `id` generation for files added on canvas (images). By default, an SHA-1 digest of the file is used.
679
701
 
680
- <pre>
681
- isInvisiblySmallElement(element: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement</a>): boolean
682
- </pre>
683
-
684
- **How to use**
685
-
686
- ```js
687
- import { isInvisiblySmallElement } from "@excalidraw/excalidraw";
702
+ ```
703
+ (file: File) => string | Promise<string>
688
704
  ```
689
705
 
690
- Returns `true` if element is invisibly small (e.g. width & height are zero).
706
+ #### `onLinkOpen`
691
707
 
692
- #### `getElementMap`
708
+ This prop if passed will be triggered when clicked on link. To handle the redirect yourself (such as when using your own router for internal links), you must call `event.preventDefault()`.
693
709
 
694
- **_Signature_**
695
-
696
- <pre>
697
- getElementsMap(elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement[]</a>): {[id: string]: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement</a>}
698
- </pre>
699
-
700
- **How to use**
710
+ ```
711
+ (element: ExcalidrawElement, event: CustomEvent<{ nativeEvent: MouseEvent }>) => void
712
+ ```
701
713
 
702
- ```js
703
- import { getElementsMap } from "@excalidraw/excalidraw";
714
+ Example:
715
+
716
+ ```ts
717
+ const history = useHistory();
718
+
719
+ // open internal links using the app's router, but opens external links in
720
+ // a new tab/window
721
+ const onLinkOpen: ExcalidrawProps["onLinkOpen"] = useCallback(
722
+ (element, event) => {
723
+ const link = element.link;
724
+ const { nativeEvent } = event.detail;
725
+ const isNewTab = nativeEvent.ctrlKey || nativeEvent.metaKey;
726
+ const isNewWindow = nativeEvent.shiftKey;
727
+ const isInternalLink =
728
+ link.startsWith("/") || link.includes(window.location.origin);
729
+ if (isInternalLink && !isNewTab && !isNewWindow) {
730
+ history.push(link.replace(window.location.origin, ""));
731
+ // signal that we're handling the redirect ourselves
732
+ event.preventDefault();
733
+ }
734
+ },
735
+ [history],
736
+ );
704
737
  ```
705
738
 
706
- This function returns an object where each element is mapped to its id.
739
+ ### Does it support collaboration ?
740
+
741
+ 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).
707
742
 
708
743
  ### Restore utilities
709
744
 
@@ -761,19 +796,6 @@ import { restore } from "@excalidraw/excalidraw";
761
796
 
762
797
  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).
763
798
 
764
- #### `serializeAsJSON`
765
-
766
- **_Signature_**
767
-
768
- <pre>
769
- serializeAsJSON({
770
- elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement[]</a>,
771
- appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a>,
772
- }): string
773
- </pre>
774
-
775
- 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).
776
-
777
799
  ### Export utilities
778
800
 
779
801
  #### `exportToCanvas`
@@ -785,14 +807,17 @@ Takes the scene elements and state and returns a JSON string. Deleted `elements`
785
807
  elements,
786
808
  appState
787
809
  getDimensions,
788
- }: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/packages/utils.ts#L10">ExportOpts</a>
810
+ files
811
+ }: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/packages/utils.ts#L12">ExportOpts</a>
789
812
  </pre>
790
813
 
791
814
  | Name | Type | Default | Description |
792
815
  | --- | --- | --- | --- |
793
816
  | elements | [Excalidraw Element []](https://github.com/excalidraw/excalidraw/blob/master/src/element/types) | | The elements to be exported to canvas |
794
817
  | appState | [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/packages/utils.ts#L12) | [defaultAppState](https://github.com/excalidraw/excalidraw/blob/master/src/appState.ts#L11) | The app state of the scene |
795
- | getDimensions | `(width: number, height: number) => {width: number, height: number, scale: number)` | `(width, height) => ({ width, height, scale: 1 })` | A function which returns the width, height and scale with which canvas is to be exported. |
818
+ | getDimensions | `(width: number, height: number) => { width: number, height: number, scale?: number }` | undefined | A function which returns the `width`, `height`, and optionally `scale` (defaults `1`), with which canvas is to be exported. |
819
+ | maxWidthOrHeight | `number` | undefined | The maximum width or height of the exported image. If provided, `getDimensions` is ignored. |
820
+ | files | [BinaryFiles](The [`BinaryFiles`](<[BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64)>) | undefined | The files added to the scene. |
796
821
 
797
822
  **How to use**
798
823
 
@@ -828,8 +853,6 @@ import { exportToBlob } from "@excalidraw/excalidraw";
828
853
 
829
854
  Returns a promise which resolves with a [blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob). It internally uses [canvas.ToBlob](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob).
830
855
 
831
- Note: `appState.exportBackground` is always set to `true` if exporting to `image/jpeg` to ensure the alpha channel isn't compressed to black.
832
-
833
856
  #### `exportToSvg`
834
857
 
835
858
  **_Signature_**
@@ -840,6 +863,7 @@ exportToSvg({
840
863
  appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a>,
841
864
  exportPadding?: number,
842
865
  metadata?: string,
866
+ files?: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64">BinaryFiles</a>
843
867
  })
844
868
  </pre>
845
869
 
@@ -848,6 +872,7 @@ exportToSvg({
848
872
  | elements | [Excalidraw Element []](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78) | | The elements to exported as svg |
849
873
  | 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 |
850
874
  | exportPadding | number | 10 | The padding to be added on canvas |
875
+ | files | [BinaryFiles](The [`BinaryFiles`](<[BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64)>) | undefined | The files added to the scene. |
851
876
 
852
877
  This function returns a promise which resolves to svg of the exported drawing.
853
878
 
@@ -860,25 +885,49 @@ This function returns a promise which resolves to svg of the exported drawing.
860
885
  | exportWithDarkMode | boolean | false | Indicates whether to export with dark mode |
861
886
  | exportEmbedScene | boolean | false | Indicates whether scene data should be embedded in svg. This will increase the svg size. |
862
887
 
863
- ### FONT_FAMILY
888
+ ### Extra API's
889
+
890
+ #### `serializeAsJSON`
891
+
892
+ **_Signature_**
893
+
894
+ <pre>
895
+ serializeAsJSON({
896
+ elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement[]</a>,
897
+ appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42">AppState</a>,
898
+ }): string
899
+ </pre>
900
+
901
+ 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).
902
+
903
+ #### `getSceneVersion`
864
904
 
865
905
  **How to use**
866
906
 
867
- ```js
868
- import { FONT_FAMILY } from "@excalidraw/excalidraw";
869
- ```
907
+ <pre>
908
+ import { getSceneVersion } from "@excalidraw/excalidraw";
909
+ getSceneVersion(elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement[]</a>)
910
+ </pre>
870
911
 
871
- `FONT_FAMILY` contains all the font families used in `Excalidraw` as explained below
912
+ This function returns the current scene version.
872
913
 
873
- | Font Family | Description |
874
- | ----------- | -------------------- |
875
- | Virgil | The handwritten font |
876
- | Helvetica | The Normal Font |
877
- | Cascadia | The Code Font |
914
+ #### `isInvisiblySmallElement`
878
915
 
879
- Defaults to `FONT_FAMILY.Virgil` unless passed in `initialData.appState.currentItemFontFamily`.
916
+ **_Signature_**
880
917
 
881
- ### loadLibraryFromBlob
918
+ <pre>
919
+ isInvisiblySmallElement(element: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement</a>): boolean
920
+ </pre>
921
+
922
+ **How to use**
923
+
924
+ ```js
925
+ import { isInvisiblySmallElement } from "@excalidraw/excalidraw";
926
+ ```
927
+
928
+ Returns `true` if element is invisibly small (e.g. width & height are zero).
929
+
930
+ #### `loadLibraryFromBlob`
882
931
 
883
932
  ```js
884
933
  import { loadLibraryFromBlob } from "@excalidraw/excalidraw";
@@ -892,7 +941,7 @@ loadLibraryFromBlob(blob: <a href="https://developer.mozilla.org/en-US/docs/Web/
892
941
 
893
942
  This function loads the library from the blob.
894
943
 
895
- ### loadFromBlob
944
+ #### `loadFromBlob`
896
945
 
897
946
  **How to use**
898
947
 
@@ -908,7 +957,7 @@ loadFromBlob(blob: <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blo
908
957
 
909
958
  This function loads the scene data from the blob. If you pass `localAppState`, `localAppState` value will be preferred over the `appState` derived from `blob`
910
959
 
911
- ### getFreeDrawSvgPath
960
+ #### `getFreeDrawSvgPath`
912
961
 
913
962
  **How to use**
914
963
 
@@ -924,6 +973,103 @@ getFreeDrawSvgPath(element: <a href="https://github.com/excalidraw/excalidraw/bl
924
973
 
925
974
  This function returns the free draw svg path for the element.
926
975
 
976
+ #### `isLinearElement`
977
+
978
+ **How to use**
979
+
980
+ ```js
981
+ import { isLinearElement } from "@excalidraw/excalidraw";
982
+ ```
983
+
984
+ **Signature**
985
+
986
+ <pre>
987
+ isLinearElement(elementType?: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L80">ExcalidrawElement</a>): boolean
988
+ </pre>
989
+
990
+ This function returns true if the element is linear type (`arrow` |`line`) else returns false.
991
+
992
+ #### `getNonDeletedElements`
993
+
994
+ **How to use**
995
+
996
+ ```js
997
+ import { getNonDeletedElements } from "@excalidraw/excalidraw";
998
+ ```
999
+
1000
+ **Signature**
1001
+
1002
+ <pre>
1003
+ getNonDeletedElements(elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L80"> readonly ExcalidrawElement[]</a>): as readonly <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L90">NonDeletedExcalidrawElement[]</a>
1004
+ </pre>
1005
+
1006
+ This function returns an array of deleted elements.
1007
+
1008
+ ### Exported constants
1009
+
1010
+ #### `FONT_FAMILY`
1011
+
1012
+ **How to use**
1013
+
1014
+ ```js
1015
+ import { FONT_FAMILY } from "@excalidraw/excalidraw";
1016
+ ```
1017
+
1018
+ `FONT_FAMILY` contains all the font families used in `Excalidraw` as explained below
1019
+
1020
+ | Font Family | Description |
1021
+ | ----------- | -------------------- |
1022
+ | Virgil | The handwritten font |
1023
+ | Helvetica | The Normal Font |
1024
+ | Cascadia | The Code Font |
1025
+
1026
+ Defaults to `FONT_FAMILY.Virgil` unless passed in `initialData.appState.currentItemFontFamily`.
1027
+
1028
+ #### `THEME`
1029
+
1030
+ **How to use**
1031
+
1032
+ ```js
1033
+ import { THEME } from "@excalidraw/excalidraw";
1034
+ ```
1035
+
1036
+ `THEME` contains all the themes supported by `Excalidraw` as explained below
1037
+
1038
+ | Theme | Description |
1039
+ | ----- | --------------- |
1040
+ | LIGHT | The light theme |
1041
+ | DARK | The Dark theme |
1042
+
1043
+ Defaults to `THEME.LIGHT` unless passed in `initialData.appState.theme`
1044
+
927
1045
  ## Need help?
928
1046
 
929
1047
  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).
1048
+
1049
+ ### Development
1050
+
1051
+ #### Install the dependencies
1052
+
1053
+ ```bash
1054
+ yarn
1055
+ ```
1056
+
1057
+ #### Start the server
1058
+
1059
+ ```bash
1060
+ yarn start
1061
+ ```
1062
+
1063
+ [http://localhost:3001](http://localhost:3001) will open in your default browser.
1064
+
1065
+ The example is same as the [codesandbox example](https://ehlz3.csb.app/)
1066
+
1067
+ #### Create a test release
1068
+
1069
+ You can create a test release by posting the below comment in your pull request
1070
+
1071
+ ```
1072
+ @excalibot release package
1073
+ ```
1074
+
1075
+ Once the version is released `@excalibot` will post a comment with the release version.