@dwelle/excalidraw 0.4.0-532db6e → 0.4.0-5b8c704
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 +10 -0
- package/README.md +197 -9
- package/dist/excalidraw.development.js +210 -111
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +1 -1
- package/types/actions/actionAddToLibrary.d.ts +18 -3
- package/types/actions/actionBoundText.d.ts +6 -1
- package/types/actions/actionCanvas.d.ts +48 -8
- package/types/actions/actionClipboard.d.ts +48 -5
- package/types/actions/actionDeleteSelected.d.ts +18 -3
- package/types/actions/actionExport.d.ts +54 -9
- package/types/actions/actionFinalize.d.ts +12 -2
- package/types/actions/actionLinearEditor.d.ts +6 -1
- package/types/actions/actionMenu.d.ts +17 -2
- package/types/actions/actionProperties.d.ts +78 -13
- package/types/actions/actionStyles.d.ts +6 -1
- package/types/actions/actionToggleGridMode.d.ts +7 -1
- package/types/actions/actionToggleLock.d.ts +6 -1
- package/types/actions/actionToggleStats.d.ts +6 -1
- package/types/actions/actionToggleViewMode.d.ts +7 -1
- package/types/actions/actionToggleZenMode.d.ts +7 -1
- package/types/actions/types.d.ts +1 -1
- package/types/components/App.d.ts +7 -50
- package/types/components/ContextMenu.d.ts +8 -21
- package/types/components/JSONExportDialog.d.ts +4 -2
- package/types/components/LayerUI.d.ts +2 -2
- package/types/components/LibraryMenuHeaderContent.d.ts +23 -0
- package/types/components/MobileMenu.d.ts +5 -8
- package/types/components/UserList.d.ts +0 -2
- package/types/components/WelcomeScreen.d.ts +60 -8
- package/types/components/dropdownMenu/DropdownMenu.d.ts +53 -0
- package/types/components/dropdownMenu/DropdownMenuContent.d.ts +11 -0
- package/types/components/dropdownMenu/DropdownMenuGroup.d.ts +11 -0
- package/types/components/dropdownMenu/DropdownMenuItem.d.ts +15 -0
- package/types/components/dropdownMenu/DropdownMenuSeparator.d.ts +5 -0
- package/types/components/dropdownMenu/DropdownMenuTrigger.d.ts +9 -0
- package/types/components/dropdownMenu/dropdownMenuUtils.d.ts +3 -0
- package/types/components/footer/Footer.d.ts +13 -0
- package/types/components/footer/FooterCenter.d.ts +8 -0
- package/types/components/mainMenu/DefaultItems.d.ts +44 -0
- package/types/components/mainMenu/MainMenu.d.ts +67 -0
- package/types/constants.d.ts +0 -3
- package/types/element/Hyperlink.d.ts +6 -1
- package/types/element/linearElementEditor.d.ts +7 -2
- package/types/element/textElement.d.ts +7 -0
- package/types/element/textWysiwyg.d.ts +6 -1
- package/types/keys.d.ts +2 -0
- package/types/packages/excalidraw/example/CustomFooter.d.ts +5 -0
- package/types/packages/excalidraw/example/MobileFooter.d.ts +5 -0
- package/types/packages/excalidraw/index.d.ts +7 -0
- package/types/types.d.ts +26 -4
- package/types/utils.d.ts +4 -0
- package/types/components/Footer.d.ts +0 -10
- package/types/components/MenuItem.d.ts +0 -11
- package/types/components/MenuUtils.d.ts +0 -1
- package/types/components/WelcomeScreenDecor.d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,16 @@ Please add the latest change on the top under the correct section.
|
|
|
13
13
|
|
|
14
14
|
## Unreleased
|
|
15
15
|
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- Expose component API for the Excalidraw main menu [#6034](https://github.com/excalidraw/excalidraw/pull/6034), You can read more about its usage [here](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#MainMenu)
|
|
19
|
+
|
|
20
|
+
- Render Footer as a component instead of render prop [#5970](https://github.com/excalidraw/excalidraw/pull/5970). You can read more about its usage [here](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#Footer)
|
|
21
|
+
|
|
22
|
+
#### BREAKING CHANGE
|
|
23
|
+
|
|
24
|
+
- With this change, the prop `renderFooter` is now removed.
|
|
25
|
+
|
|
16
26
|
### Excalidraw schema
|
|
17
27
|
|
|
18
28
|
- Merged `appState.currentItemStrokeSharpness` and `appState.currentItemLinearStrokeSharpness` into `appState.currentItemRoundness`. Renamed `changeSharpness` action to `changeRoundness`. Excalidraw element's `strokeSharpness` was changed to `roundness`. Check the PR for types and more details [#5553](https://github.com/excalidraw/excalidraw/pull/5553).
|
package/README.md
CHANGED
|
@@ -380,6 +380,156 @@ For a complete list of variables, check [theme.scss](https://github.com/excalidr
|
|
|
380
380
|
|
|
381
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
382
|
|
|
383
|
+
### Component API
|
|
384
|
+
|
|
385
|
+
#### Footer
|
|
386
|
+
|
|
387
|
+
Earlier we were using `renderFooter` prop to render custom footer which was removed in [#5970](https://github.com/excalidraw/excalidraw/pull/5970). Now you can pass a `Footer` component instead to render the custom UI for footer.
|
|
388
|
+
|
|
389
|
+
You will need to import the `Footer` component from the package and wrap your component with the Footer component. The `Footer` should a valid React Node.
|
|
390
|
+
|
|
391
|
+
**Usage**
|
|
392
|
+
|
|
393
|
+
```js
|
|
394
|
+
import { Footer } from "@excalidraw/excalidraw";
|
|
395
|
+
|
|
396
|
+
const CustomFooter = () => <button> custom button</button>;
|
|
397
|
+
const App = () => {
|
|
398
|
+
return (
|
|
399
|
+
<Excalidraw>
|
|
400
|
+
<Footer>
|
|
401
|
+
<CustomFooter />
|
|
402
|
+
</Footer>
|
|
403
|
+
</Excalidraw>
|
|
404
|
+
);
|
|
405
|
+
};
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
This will only for `Desktop` devices.
|
|
409
|
+
|
|
410
|
+
For `mobile` you will need to render it inside the [MainMenu](#mainmenu). You can use the [`useDevice`](#useDevice) hook to check the type of device, this will be available only inside the `children` of `Excalidraw` component.
|
|
411
|
+
|
|
412
|
+
```js
|
|
413
|
+
import { useDevice, Footer } from "@excalidraw/excalidraw";
|
|
414
|
+
|
|
415
|
+
const MobileFooter = ({
|
|
416
|
+
}) => {
|
|
417
|
+
const device = useDevice();
|
|
418
|
+
if (device.isMobile) {
|
|
419
|
+
return (
|
|
420
|
+
<Footer>
|
|
421
|
+
<button
|
|
422
|
+
className="custom-footer"
|
|
423
|
+
onClick={() => alert("This is custom footer in mobile menu")}
|
|
424
|
+
>
|
|
425
|
+
{" "}
|
|
426
|
+
custom footer{" "}
|
|
427
|
+
</button>
|
|
428
|
+
</Footer>
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
return null;
|
|
432
|
+
|
|
433
|
+
};
|
|
434
|
+
const App = () => {
|
|
435
|
+
<Excalidraw>
|
|
436
|
+
<MainMenu>
|
|
437
|
+
<MainMenu.Item> Item1 </MainMenu.Item>
|
|
438
|
+
<MainMenu.Item> Item 2 </>
|
|
439
|
+
<MobileFooter/>
|
|
440
|
+
</MainMenu>
|
|
441
|
+
</Excalidraw>
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
You can visit the[ example](https://ehlz3.csb.app/) for working demo.
|
|
447
|
+
|
|
448
|
+
#### MainMenu
|
|
449
|
+
|
|
450
|
+
By default Excalidraw will render the `MainMenu` with default options. If you want to customise the `MainMenu`, you can pass the `MainMenu` component with the list options. You can visit [codesandbox example](https://ehlz3.csb.app/) for a working demo.
|
|
451
|
+
|
|
452
|
+
**Usage**
|
|
453
|
+
|
|
454
|
+
```js
|
|
455
|
+
import { MainMenu } from "@excalidraw/excalidraw";
|
|
456
|
+
const App = () => {
|
|
457
|
+
<Excalidraw>
|
|
458
|
+
<MainMenu>
|
|
459
|
+
<MainMenu.Item> Item1 </MainMenu.Item>
|
|
460
|
+
<MainMenu.Item> Item 2 </>
|
|
461
|
+
</MainMenu>
|
|
462
|
+
</Excalidraw>
|
|
463
|
+
}
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
**MainMenu**
|
|
467
|
+
|
|
468
|
+
This is the `MainMenu` component which you need to import to render the menu with custom options.
|
|
469
|
+
|
|
470
|
+
**MainMenu.Item**
|
|
471
|
+
|
|
472
|
+
To render an item, its recommended to use `MainMenu.Item`
|
|
473
|
+
|
|
474
|
+
| Prop | Type | Default | Description |
|
|
475
|
+
| --- | --- | --- | --- |
|
|
476
|
+
| `icon` | `JSX.Element` | `undefined` | The icon used in the menu item |
|
|
477
|
+
| `shortcut` | `string` | `undefined` | The shortcut to be shown for the menu item |
|
|
478
|
+
| `children` | `React.ReactNode` | `undefined` | The content of the menu item |
|
|
479
|
+
| `onClick` | `Function` | `undefined` | The click handler will be triggered when clicked on menu item. If passed the item is rendered as a button. |
|
|
480
|
+
| `className` | `string` | "" | The class names to be added to the menu item |
|
|
481
|
+
| `link` | `string` | `undefined` | If `link` is passed the item is rendered as an anchor element. |
|
|
482
|
+
| `style` | `React.CSSProperties` | `undefined` | The inline styles to be added to the menu item |
|
|
483
|
+
|
|
484
|
+
**MainMenu.DefaultItems**
|
|
485
|
+
|
|
486
|
+
For the items which are shown in the menu in [excalidraw.com](https://excalidraw.com), you can use `MainMenu.DefaultItems`
|
|
487
|
+
|
|
488
|
+
```js
|
|
489
|
+
import { MainMenu } from "@excalidraw/excalidraw";
|
|
490
|
+
const App = () => {
|
|
491
|
+
<Excalidraw>
|
|
492
|
+
<MainMenu>
|
|
493
|
+
<MainMenu.DefaultItems.Socials/>
|
|
494
|
+
<MainMenu.DefaultItems.Export/>
|
|
495
|
+
<MainMenu.Item> Item1 </MainMenu.Item>
|
|
496
|
+
<MainMenu.Item> Item 2 </>
|
|
497
|
+
</MainMenu>
|
|
498
|
+
</Excalidraw>
|
|
499
|
+
}
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
Here is a [complete list](https://github.com/excalidraw/excalidraw/blob/master/src/components/mainMenu/DefaultItems.tsx) of the default items.
|
|
503
|
+
|
|
504
|
+
**MainMenu.Group**
|
|
505
|
+
|
|
506
|
+
To Group item in the main menu, you can use `MainMenu.Group`
|
|
507
|
+
|
|
508
|
+
```js
|
|
509
|
+
import { MainMenu } from "@excalidraw/excalidraw";
|
|
510
|
+
const App = () => {
|
|
511
|
+
<Excalidraw>
|
|
512
|
+
<MainMenu>
|
|
513
|
+
<MainMenu.Group title="Excalidraw items">
|
|
514
|
+
<MainMenu.DefaultItems.Socials/>
|
|
515
|
+
<MainMenu.DefaultItems.Export/>
|
|
516
|
+
</MainMenu.Group>
|
|
517
|
+
<MainMenu.Group title="custom items">
|
|
518
|
+
<MainMenu.Item> Item1 </MainMenu.Item>
|
|
519
|
+
<MainMenu.Item> Item 2 </>
|
|
520
|
+
</MainMenu.Group>
|
|
521
|
+
</MainMenu>
|
|
522
|
+
</Excalidraw>
|
|
523
|
+
}
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
| Prop | Type | Default | Description |
|
|
527
|
+
| --- | --- | --- | --- |
|
|
528
|
+
| `title` | `string` | `undefined` | The `title` for the grouped items |
|
|
529
|
+
| `className` | `string` | "" | The `classname` to be added to the group |
|
|
530
|
+
| `style` | `React.CSsSProperties` | `undefined` | The inline `styles` to be added to the group |
|
|
531
|
+
| `children ` | `React.ReactNode` | `undefined` | The content of the `Menu Group` |
|
|
532
|
+
|
|
383
533
|
### Props
|
|
384
534
|
|
|
385
535
|
| Name | Type | Default | Description |
|
|
@@ -392,7 +542,6 @@ No, Excalidraw package doesn't come with collaboration built in, since the imple
|
|
|
392
542
|
| [`onPointerUpdate`](#onPointerUpdate) | Function | | Callback triggered when mouse pointer is updated. |
|
|
393
543
|
| [`langCode`](#langCode) | string | `en` | Language code string |
|
|
394
544
|
| [`renderTopRightUI`](#renderTopRightUI) | Function | | Function that renders custom UI in top right corner |
|
|
395
|
-
| [`renderFooter `](#renderFooter) | Function | | Function that renders custom UI footer |
|
|
396
545
|
| [`renderCustomStats`](#renderCustomStats) | Function | | Function that can be used to render custom stats on the stats dialog. |
|
|
397
546
|
| [`renderSIdebar`](#renderSIdebar) | Function | | Render function that renders custom sidebar. |
|
|
398
547
|
| [`viewModeEnabled`](#viewModeEnabled) | boolean | | This implies if the app is in view mode. |
|
|
@@ -613,14 +762,6 @@ import { defaultLang, languages } from "@excalidraw/excalidraw";
|
|
|
613
762
|
|
|
614
763
|
A function returning JSX to render custom UI in the top right corner of the app.
|
|
615
764
|
|
|
616
|
-
#### `renderFooter`
|
|
617
|
-
|
|
618
|
-
<pre>
|
|
619
|
-
(isMobile: boolean, appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L79">AppState</a>) => JSX | null
|
|
620
|
-
</pre>
|
|
621
|
-
|
|
622
|
-
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).
|
|
623
|
-
|
|
624
765
|
#### `renderCustomStats`
|
|
625
766
|
|
|
626
767
|
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.
|
|
@@ -1353,6 +1494,53 @@ viewportCoordsToSceneCoords({clientX: number, clientY: number}, appState: <a hre
|
|
|
1353
1494
|
|
|
1354
1495
|
This function returns equivalent scene coords for the provided viewport coords in params.
|
|
1355
1496
|
|
|
1497
|
+
#### useDevice
|
|
1498
|
+
|
|
1499
|
+
This hook can be used to check the type of device which is being used. It can only be used inside the `children` of `Excalidraw` component
|
|
1500
|
+
|
|
1501
|
+
```js
|
|
1502
|
+
import { useDevice, Footer } from "@excalidraw/excalidraw";
|
|
1503
|
+
|
|
1504
|
+
const MobileFooter = ({
|
|
1505
|
+
}) => {
|
|
1506
|
+
const device = useDevice();
|
|
1507
|
+
if (device.isMobile) {
|
|
1508
|
+
return (
|
|
1509
|
+
<Footer>
|
|
1510
|
+
<button
|
|
1511
|
+
className="custom-footer"
|
|
1512
|
+
onClick={() => alert("This is custom footer in mobile menu")}
|
|
1513
|
+
>
|
|
1514
|
+
{" "}
|
|
1515
|
+
custom footer{" "}
|
|
1516
|
+
</button>
|
|
1517
|
+
</Footer>
|
|
1518
|
+
);
|
|
1519
|
+
}
|
|
1520
|
+
return null;
|
|
1521
|
+
|
|
1522
|
+
};
|
|
1523
|
+
const App = () => {
|
|
1524
|
+
<Excalidraw>
|
|
1525
|
+
<MainMenu>
|
|
1526
|
+
<MainMenu.Item> Item1 </MainMenu.Item>
|
|
1527
|
+
<MainMenu.Item> Item 2 </>
|
|
1528
|
+
<MobileFooter/>
|
|
1529
|
+
</MainMenu>
|
|
1530
|
+
</Excalidraw>
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
```
|
|
1534
|
+
|
|
1535
|
+
The `device` has the following `attributes`
|
|
1536
|
+
|
|
1537
|
+
| Name | Type | Description |
|
|
1538
|
+
| --- | --- | --- |
|
|
1539
|
+
| `isSmScreen` | `boolean` | Set to `true` when the device small screen is small (Width < `640px` ) |
|
|
1540
|
+
| `isMobile` | `boolean` | Set to `true` when the device is `mobile` |
|
|
1541
|
+
| `isTouchScreen` | `boolean` | Set to `true` for `touch` devices |
|
|
1542
|
+
| `canDeviceFitSidebar` | `boolean` | Implies whether there is enough space to fit the `sidebar` |
|
|
1543
|
+
|
|
1356
1544
|
### Exported constants
|
|
1357
1545
|
|
|
1358
1546
|
#### `FONT_FAMILY`
|