@excalidraw/excalidraw 0.12.0-76cf560 → 0.12.0-78e254f
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 +2 -0
- package/README.md +56 -12
- package/dist/excalidraw.development.js +87 -43
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +1 -1
- package/types/actions/actionAddToLibrary.d.ts +6 -6
- package/types/actions/actionBoundText.d.ts +2 -2
- package/types/actions/actionCanvas.d.ts +16 -16
- package/types/actions/actionClipboard.d.ts +10 -10
- package/types/actions/actionDeleteSelected.d.ts +6 -6
- package/types/actions/actionExport.d.ts +18 -18
- package/types/actions/actionFinalize.d.ts +4 -4
- package/types/actions/actionLinearEditor.d.ts +2 -2
- package/types/actions/actionMenu.d.ts +6 -6
- package/types/actions/actionProperties.d.ts +26 -26
- package/types/actions/actionStyles.d.ts +2 -2
- package/types/actions/actionToggleGridMode.d.ts +2 -2
- package/types/actions/actionToggleLock.d.ts +2 -2
- package/types/actions/actionToggleStats.d.ts +2 -2
- package/types/actions/actionToggleViewMode.d.ts +2 -2
- package/types/actions/actionToggleZenMode.d.ts +2 -2
- package/types/appState.d.ts +2 -2
- package/types/components/App.d.ts +6 -1
- package/types/components/HintViewer.d.ts +3 -2
- package/types/components/LayerUI.d.ts +2 -1
- package/types/components/LibraryMenu.d.ts +14 -5
- package/types/components/LibraryMenuHeaderContent.d.ts +12 -0
- package/types/components/LibraryMenuItems.d.ts +2 -14
- package/types/components/LibraryUnit.d.ts +2 -3
- package/types/components/MobileMenu.d.ts +4 -3
- package/types/components/Sidebar/Sidebar.d.ts +73 -0
- package/types/components/Sidebar/SidebarHeader.d.ts +20 -0
- package/types/components/Sidebar/common.d.ts +15 -0
- package/types/components/hoc/withUpstreamOverride.d.ts +10 -0
- package/types/constants.d.ts +7 -1
- package/types/data/types.d.ts +16 -1
- package/types/element/Hyperlink.d.ts +2 -2
- package/types/element/image.d.ts +1 -1
- package/types/element/linearElementEditor.d.ts +3 -3
- package/types/keys.d.ts +3 -3
- package/types/packages/excalidraw/example/App.d.ts +2 -1
- package/types/packages/excalidraw/example/sidebar/{Sidebar.d.ts → ExampleSidebar.d.ts} +1 -1
- package/types/packages/excalidraw/index.d.ts +1 -0
- package/types/types.d.ts +8 -2
- package/types/components/SidebarLockButton.d.ts +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,8 @@ Please add the latest change on the top under the correct section.
|
|
|
17
17
|
|
|
18
18
|
#### Features
|
|
19
19
|
|
|
20
|
+
- Support rendering custom sidebar using [`renderSidebar`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#renderSidebar) prop ([#5663](https://github.com/excalidraw/excalidraw/pull/5663)).
|
|
21
|
+
- Add [`toggleMenu`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#onMenuToggle) prop to toggle specific menu open/close state ([#5663](https://github.com/excalidraw/excalidraw/pull/5663)).
|
|
20
22
|
- Support [theme](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#theme) to be semi-controlled [#5660](https://github.com/excalidraw/excalidraw/pull/5660).
|
|
21
23
|
- Added support for storing [`customData`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#storing-custom-data-to-excalidraw-elements) on Excalidraw elements [#5592].
|
|
22
24
|
- Added `exportPadding?: number;` to [exportToCanvas](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#exporttocanvas) and [exportToBlob](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#exporttoblob). The default value of the padding is 10.
|
package/README.md
CHANGED
|
@@ -376,13 +376,17 @@ Most notably, you can customize the primary colors, by overriding these variable
|
|
|
376
376
|
|
|
377
377
|
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.
|
|
378
378
|
|
|
379
|
+
### Does this package support collaboration ?
|
|
380
|
+
|
|
381
|
+
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).
|
|
382
|
+
|
|
379
383
|
### Props
|
|
380
384
|
|
|
381
385
|
| Name | Type | Default | Description |
|
|
382
386
|
| --- | --- | --- | --- |
|
|
383
387
|
| [`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. |
|
|
384
|
-
| [`initialData`](#initialData) | <
|
|
385
|
-
| [`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) | <
|
|
388
|
+
| [`initialData`](#initialData) | <code>{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> } </code> | null | The initial data with which app loads. |
|
|
389
|
+
| [`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) | <code>{ current: { readyPromise: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/utils.ts#L317">resolvablePromise</a> } }</code> | | Ref to be passed to Excalidraw |
|
|
386
390
|
| [`onCollabButtonClick`](#onCollabButtonClick) | Function | | Callback to be triggered when the collab button is clicked |
|
|
387
391
|
| [`isCollaborating`](#isCollaborating) | `boolean` | | This implies if the app is in collaboration mode |
|
|
388
392
|
| [`onPointerUpdate`](#onPointerUpdate) | Function | | Callback triggered when mouse pointer is updated. |
|
|
@@ -390,22 +394,23 @@ For a complete list of variables, check [theme.scss](https://github.com/excalidr
|
|
|
390
394
|
| [`renderTopRightUI`](#renderTopRightUI) | Function | | Function that renders custom UI in top right corner |
|
|
391
395
|
| [`renderFooter `](#renderFooter) | Function | | Function that renders custom UI footer |
|
|
392
396
|
| [`renderCustomStats`](#renderCustomStats) | Function | | Function that can be used to render custom stats on the stats dialog. |
|
|
397
|
+
| [`renderSIdebar`](#renderSIdebar) | Function | | Render function that renders custom sidebar. |
|
|
393
398
|
| [`viewModeEnabled`](#viewModeEnabled) | boolean | | This implies if the app is in view mode. |
|
|
394
399
|
| [`zenModeEnabled`](#zenModeEnabled) | boolean | | This implies if the zen mode is enabled |
|
|
395
400
|
| [`gridModeEnabled`](#gridModeEnabled) | boolean | | This implies if the grid mode is enabled |
|
|
396
401
|
| [`libraryReturnUrl`](#libraryReturnUrl) | string | | What URL should [libraries.excalidraw.com](https://libraries.excalidraw.com) be installed to |
|
|
397
402
|
| [`theme`](#theme) | [THEME.LIGHT](#THEME-1) | [THEME.DARK](#THEME-1) | [THEME.LIGHT](#THEME-1) | The theme of the Excalidraw component |
|
|
398
403
|
| [`name`](#name) | string | | Name of the drawing |
|
|
399
|
-
| [`UIOptions`](#UIOptions) | <
|
|
400
|
-
| [`onPaste`](#onPaste) | <
|
|
404
|
+
| [`UIOptions`](#UIOptions) | <code>{ canvasActions: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L208"> CanvasActions<a/> }</code> | [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) |
|
|
405
|
+
| [`onPaste`](#onPaste) | <code>(data: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/clipboard.ts#L21">ClipboardData</a>, event: ClipboardEvent | null) => boolean</code> | | Callback to be triggered if passed when the something is pasted in to the scene |
|
|
401
406
|
| [`detectScroll`](#detectScroll) | boolean | true | Indicates whether to update the offsets when nearest ancestor is scrolled. |
|
|
402
407
|
| [`handleKeyboardGlobally`](#handleKeyboardGlobally) | boolean | false | Indicates whether to bind the keyboard events to document. |
|
|
403
|
-
| [`onLibraryChange`](#onLibraryChange) | <
|
|
408
|
+
| [`onLibraryChange`](#onLibraryChange) | <code>(items: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200">LibraryItems</a>) => void | Promise<any> </code> | | The callback if supplied is triggered when the library is updated and receives the library items. |
|
|
404
409
|
| [`autoFocus`](#autoFocus) | boolean | false | Implies whether to focus the Excalidraw component on page load |
|
|
405
410
|
| [`generateIdForFile`](#generateIdForFile) | `(file: File) => string | Promise<string>` | Allows you to override `id` generation for files added on canvas |
|
|
406
|
-
| [`onLinkOpen`](#onLinkOpen) | <
|
|
407
|
-
| [`onPointerDown`](#onPointerDown) | <
|
|
408
|
-
| [`onScrollChange`](#onScrollChange) | (scrollX: number, scrollY: number) | | This prop if passed gets triggered when scrolling the canvas. |
|
|
411
|
+
| [`onLinkOpen`](#onLinkOpen) | <code>(element: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L106">NonDeletedExcalidrawElement</a>, event: CustomEvent) </code> | | This prop if passed will be triggered when link of an element is clicked. |
|
|
412
|
+
| [`onPointerDown`](#onPointerDown) | <code>(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</code> | | This prop if passed gets triggered on pointer down evenets |
|
|
413
|
+
| [`onScrollChange`](#onScrollChange) | <code>(scrollX: number, scrollY: number)</code> | | This prop if passed gets triggered when scrolling the canvas. |
|
|
409
414
|
|
|
410
415
|
### Dimensions of Excalidraw
|
|
411
416
|
|
|
@@ -503,6 +508,7 @@ You can pass a `ref` when you want to access some excalidraw APIs. We expose the
|
|
|
503
508
|
| [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 |
|
|
504
509
|
| [setCursor](#setCursor) | <code>(cursor: string) => void </code> | This API can be used to set customise the mouse cursor on the canvas |
|
|
505
510
|
| [resetCursor](#resetCursor) | <code>() => void </code> | This API can be used to reset to default mouse cursor on the canvas |
|
|
511
|
+
| [toggleMenu](#toggleMenu) | <code>(type: string, force?: boolean) => boolean</code> | Toggles specific menus on/off |
|
|
506
512
|
|
|
507
513
|
#### `readyPromise`
|
|
508
514
|
|
|
@@ -619,6 +625,38 @@ A function returning JSX to render custom UI footer. For example, you can use th
|
|
|
619
625
|
|
|
620
626
|
A function that can be used to render custom stats (returns JSX) in the nerd stats dialog. For example you can use this prop to render the size of the elements in the storage.
|
|
621
627
|
|
|
628
|
+
#### `renderSidebar`
|
|
629
|
+
|
|
630
|
+
<pre>
|
|
631
|
+
() => JSX | null
|
|
632
|
+
</pre>
|
|
633
|
+
|
|
634
|
+
Optional function that can render custom sidebar. This sidebar is the same that the library menu sidebar is using, and can be used for any purposes your app needs. The render function should return a `<Sidebar>` instance — a component that is exported from the Excalidraw package. It accepts `children` which can be any content you like to render inside.
|
|
635
|
+
|
|
636
|
+
The `<Sidebar>` component takes these props (all are optional except `children`):
|
|
637
|
+
|
|
638
|
+
| name | type | description |
|
|
639
|
+
| --- | --- | --- |
|
|
640
|
+
| className | string |
|
|
641
|
+
| children | <pre>React.ReactNode</pre> | Content you want to render inside the sidebar. |
|
|
642
|
+
| onClose | <pre>() => void</pre> | Invoked when the component is closed (by user, or the editor). No need to act on this event, as the editor manages the sidebar open state on its own. |
|
|
643
|
+
| onDock | <pre>(isDocked: boolean) => void</pre> | Invoked when the user toggles the dock button. |
|
|
644
|
+
| docked | boolean | Indicates whether the sidebar is docked. By default, the sidebar is undocked. If passed, the docking becomes controlled, and you are responsible for updating the `docked` state by listening on `onDock` callback. See [here](#dockedSidebarBreakpoint) for more info docking. |
|
|
645
|
+
| dockable | boolean | Indicates whether the sidebar can be docked by user (=the dock button is shown). If `false`, you can still dock programmatically by passing `docked=true` |
|
|
646
|
+
|
|
647
|
+
The sidebar will always include a header with close/dock buttons (when applicable).
|
|
648
|
+
|
|
649
|
+
You can also add custom content to the header, by rendering `<Sidebar.Header>` as a child of the `<Sidebar>` component. Note that the custom header will still include the default buttons.
|
|
650
|
+
|
|
651
|
+
The `<Sidebar.Header>` component takes these props children (all are optional):
|
|
652
|
+
|
|
653
|
+
| name | type | description |
|
|
654
|
+
| --- | --- | --- |
|
|
655
|
+
| className | string |
|
|
656
|
+
| children | <pre>React.ReactNode</pre> | Content you want to render inside the sidebar header, sibling of the header buttons. |
|
|
657
|
+
|
|
658
|
+
For example code, see the example [`App.tsx`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/example/App.tsx#L524) file.
|
|
659
|
+
|
|
622
660
|
#### `viewModeEnabled`
|
|
623
661
|
|
|
624
662
|
This prop indicates whether the app is in `view mode`. When supplied, the value takes precedence over `intialData.appState.viewModeEnabled`, the `view mode` will be fully controlled by the host app, and users won't be able to toggle it from within the app.
|
|
@@ -753,6 +791,16 @@ This API can be used to customise the mouse cursor on the canvas and has the bel
|
|
|
753
791
|
(cursor: string) => void
|
|
754
792
|
</pre>
|
|
755
793
|
|
|
794
|
+
#### `toggleMenu`
|
|
795
|
+
|
|
796
|
+
<pre>
|
|
797
|
+
(type: "library" | "customSidebar", force?: boolean) => boolean
|
|
798
|
+
</pre>
|
|
799
|
+
|
|
800
|
+
This API can be used to toggle a specific menu (currently only the sidebars), and returns whether the menu was toggled on or off. If the `force` flag passed, it will force the menu to be toggled either on/off based on the boolean passed.
|
|
801
|
+
|
|
802
|
+
This API is especially useful when you render a custom sidebar using [`renderSidebar`](#renderSidebar) prop, and you want to toggle it from your app based on a user action.
|
|
803
|
+
|
|
756
804
|
#### `resetCursor`
|
|
757
805
|
|
|
758
806
|
This API can be used to reset to default mouse cursor.
|
|
@@ -842,10 +890,6 @@ This prop if passed will be triggered when canvas is scrolled and has the below
|
|
|
842
890
|
(scrollX: number, scrollY: number) => void
|
|
843
891
|
```
|
|
844
892
|
|
|
845
|
-
### Does it support collaboration ?
|
|
846
|
-
|
|
847
|
-
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).
|
|
848
|
-
|
|
849
893
|
### Restore utilities
|
|
850
894
|
|
|
851
895
|
#### `restoreAppState`
|