@dwelle/excalidraw 0.4.0-904c06a → 0.4.0-952b0c1
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 +236 -0
- package/dist/excalidraw.development.js +276 -144
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +1 -1
- package/types/actions/actionAddToLibrary.d.ts +3 -3
- package/types/actions/actionAlign.d.ts +6 -18
- package/types/actions/actionBoundText.d.ts +3 -3
- package/types/actions/actionCanvas.d.ts +16 -29
- package/types/actions/actionClipboard.d.ts +11 -11
- package/types/actions/actionDeleteSelected.d.ts +4 -6
- package/types/actions/actionDistribute.d.ts +2 -6
- package/types/actions/actionDuplicateSelection.d.ts +1 -3
- package/types/actions/actionExport.d.ts +17 -33
- package/types/actions/actionFinalize.d.ts +3 -5
- package/types/actions/actionFlip.d.ts +2 -2
- package/types/actions/actionGroup.d.ts +4 -8
- package/types/actions/actionLinearEditor.d.ts +2 -2
- package/types/actions/actionMenu.d.ts +4 -11
- package/types/actions/actionNavigate.d.ts +1 -3
- package/types/actions/actionProperties.d.ts +26 -52
- package/types/actions/actionStyles.d.ts +1 -1
- package/types/actions/actionToggleGridMode.d.ts +2 -2
- package/types/actions/actionToggleLock.d.ts +1 -1
- package/types/actions/actionToggleStats.d.ts +1 -1
- package/types/actions/actionToggleViewMode.d.ts +2 -2
- package/types/actions/actionToggleZenMode.d.ts +2 -2
- package/types/actions/actionZindex.d.ts +4 -12
- package/types/actions/manager.d.ts +2 -1
- package/types/actions/types.d.ts +2 -4
- package/types/components/App.d.ts +5 -46
- package/types/components/Card.d.ts +7 -0
- package/types/components/CollabButton.d.ts +3 -2
- package/types/components/JSONExportDialog.d.ts +3 -1
- package/types/components/LayerUI.d.ts +2 -3
- package/types/components/LibraryMenuHeaderContent.d.ts +23 -0
- package/types/components/MobileMenu.d.ts +5 -7
- package/types/components/UserList.d.ts +0 -2
- package/types/components/WelcomeScreen.d.ts +59 -8
- package/types/components/dropdownMenu/DropdownMenu.d.ts +72 -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 +16 -0
- package/types/components/dropdownMenu/DropdownMenuItemContent.d.ts +6 -0
- package/types/components/dropdownMenu/DropdownMenuItemCustom.d.ts +8 -0
- package/types/components/dropdownMenu/DropdownMenuItemLink.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 +4 -4
- package/types/components/footer/FooterCenter.d.ts +1 -0
- package/types/components/mainMenu/DefaultItems.d.ts +47 -0
- package/types/components/mainMenu/MainMenu.d.ts +63 -0
- package/types/constants.d.ts +0 -4
- package/types/data/index.d.ts +1 -1
- package/types/element/Hyperlink.d.ts +3 -5
- package/types/element/linearElementEditor.d.ts +2 -2
- package/types/element/textElement.d.ts +1 -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 -1
- package/types/packages/utils.d.ts +2 -5
- package/types/renderer/renderScene.d.ts +1 -3
- package/types/scene/export.d.ts +62 -8
- package/types/scene/types.d.ts +9 -1
- package/types/types.d.ts +14 -3
- package/types/utils.d.ts +1 -0
- package/types/components/ActiveFile.d.ts +0 -7
- package/types/components/ClearCanvas.d.ts +0 -4
- 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
|
@@ -15,6 +15,8 @@ Please add the latest change on the top under the correct section.
|
|
|
15
15
|
|
|
16
16
|
### Features
|
|
17
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
|
+
|
|
18
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)
|
|
19
21
|
|
|
20
22
|
#### BREAKING CHANGE
|
package/README.md
CHANGED
|
@@ -405,6 +405,195 @@ const App = () => {
|
|
|
405
405
|
};
|
|
406
406
|
```
|
|
407
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 onSelect={() => window.alert("Item1")}> Item1 </MainMenu.Item>
|
|
438
|
+
<MainMenu.Item onSelect={() => window.alert("Item2")}> 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 onSelect={() => window.alert("Item1")}> Item1 </MainMenu.Item>
|
|
460
|
+
<MainMenu.Item onSelect={() => window.alert("Item2")}> 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 | Required | Default | Description |
|
|
475
|
+
| --- | --- | --- | --- | --- |
|
|
476
|
+
| `onSelect` | `Function` | Yes | `undefined` | The handler is triggered when the item is selected. |
|
|
477
|
+
| `children` | `React.ReactNode` | Yes | `undefined` | The content of the menu item |
|
|
478
|
+
| `icon` | `JSX.Element` | No | `undefined` | The icon used in the menu item |
|
|
479
|
+
| `shortcut` | `string` | No | `undefined` | The shortcut to be shown for the menu item |
|
|
480
|
+
| `className` | `string` | No | "" | The class names to be added to the menu item |
|
|
481
|
+
| `style` | `React.CSSProperties` | No | `undefined` | The inline styles to be added to the menu item |
|
|
482
|
+
| `ariaLabel` | `string` | `undefined` | No | The `aria-label` to be added to the item for accessibility |
|
|
483
|
+
| `dataTestId` | `string` | `undefined` | No | The `data-testid` to be added to the item. |
|
|
484
|
+
|
|
485
|
+
**MainMenu.ItemLink**
|
|
486
|
+
|
|
487
|
+
To render an item as a link, its recommended to use `MainMenu.ItemLink`.
|
|
488
|
+
|
|
489
|
+
**Usage**
|
|
490
|
+
|
|
491
|
+
```js
|
|
492
|
+
import { MainMenu } from "@excalidraw/excalidraw";
|
|
493
|
+
const App = () => {
|
|
494
|
+
<Excalidraw>
|
|
495
|
+
<MainMenu>
|
|
496
|
+
<MainMenu.ItemLink href="https://google.com">Google</MainMenu.ItemLink>
|
|
497
|
+
<MainMenu.ItemLink href="https://excalidraw.com">
|
|
498
|
+
Excalidraw
|
|
499
|
+
</MainMenu.ItemLink>
|
|
500
|
+
</MainMenu>
|
|
501
|
+
</Excalidraw>;
|
|
502
|
+
};
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
| Prop | Type | Required | Default | Description |
|
|
506
|
+
| --- | --- | --- | --- | --- |
|
|
507
|
+
| `href` | `string` | Yes | `undefined` | The `href` attribute to be added to the `anchor` element. |
|
|
508
|
+
| `children` | `React.ReactNode` | Yes | `undefined` | The content of the menu item |
|
|
509
|
+
| `icon` | `JSX.Element` | No | `undefined` | The icon used in the menu item |
|
|
510
|
+
| `shortcut` | `string` | No | `undefined` | The shortcut to be shown for the menu item |
|
|
511
|
+
| `className` | `string` | No | "" | The class names to be added to the menu item |
|
|
512
|
+
| `style` | `React.CSSProperties` | No | `undefined` | The inline styles to be added to the menu item |
|
|
513
|
+
| `ariaLabel` | `string` | No | `undefined` | The `aria-label` to be added to the item for accessibility |
|
|
514
|
+
| `dataTestId` | `string` | No | `undefined` | The `data-testid` to be added to the item. |
|
|
515
|
+
|
|
516
|
+
**MainMenu.ItemCustom**
|
|
517
|
+
|
|
518
|
+
To render a custom item, you can use `MainMenu.ItemCustom`.
|
|
519
|
+
|
|
520
|
+
**Usage**
|
|
521
|
+
|
|
522
|
+
```js
|
|
523
|
+
import { MainMenu } from "@excalidraw/excalidraw";
|
|
524
|
+
const App = () => {
|
|
525
|
+
<Excalidraw>
|
|
526
|
+
<MainMenu>
|
|
527
|
+
<MainMenu.ItemCustom>
|
|
528
|
+
<button
|
|
529
|
+
style={{ height: "2rem" }}
|
|
530
|
+
onClick={() => window.alert("custom menu item")}
|
|
531
|
+
>
|
|
532
|
+
{" "}
|
|
533
|
+
custom item
|
|
534
|
+
</button>
|
|
535
|
+
</MainMenu.ItemCustom>
|
|
536
|
+
</MainMenu>
|
|
537
|
+
</Excalidraw>;
|
|
538
|
+
};
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
| Prop | Type | Required | Default | Description |
|
|
542
|
+
| --- | --- | --- | --- | --- |
|
|
543
|
+
| `children` | `React.ReactNode` | Yes | `undefined` | The content of the menu item |
|
|
544
|
+
| `className` | `string` | No | "" | The class names to be added to the menu item |
|
|
545
|
+
| `style` | `React.CSSProperties` | No | `undefined` | The inline styles to be added to the menu item |
|
|
546
|
+
| `dataTestId` | `string` | No | `undefined` | The `data-testid` to be added to the item. |
|
|
547
|
+
|
|
548
|
+
**MainMenu.DefaultItems**
|
|
549
|
+
|
|
550
|
+
For the items which are shown in the menu in [excalidraw.com](https://excalidraw.com), you can use `MainMenu.DefaultItems`
|
|
551
|
+
|
|
552
|
+
```js
|
|
553
|
+
import { MainMenu } from "@excalidraw/excalidraw";
|
|
554
|
+
const App = () => {
|
|
555
|
+
<Excalidraw>
|
|
556
|
+
<MainMenu>
|
|
557
|
+
<MainMenu.DefaultItems.Socials/>
|
|
558
|
+
<MainMenu.DefaultItems.Export/>
|
|
559
|
+
<MainMenu.Item onSelect={() => window.alert("Item1")}> Item1 </MainMenu.Item>
|
|
560
|
+
<MainMenu.Item onSelect={() => window.alert("Item2")}> Item 2 </>
|
|
561
|
+
</MainMenu>
|
|
562
|
+
</Excalidraw>
|
|
563
|
+
}
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
Here is a [complete list](https://github.com/excalidraw/excalidraw/blob/master/src/components/mainMenu/DefaultItems.tsx) of the default items.
|
|
567
|
+
|
|
568
|
+
**MainMenu.Group**
|
|
569
|
+
|
|
570
|
+
To Group item in the main menu, you can use `MainMenu.Group`
|
|
571
|
+
|
|
572
|
+
```js
|
|
573
|
+
import { MainMenu } from "@excalidraw/excalidraw";
|
|
574
|
+
const App = () => {
|
|
575
|
+
<Excalidraw>
|
|
576
|
+
<MainMenu>
|
|
577
|
+
<MainMenu.Group title="Excalidraw items">
|
|
578
|
+
<MainMenu.DefaultItems.Socials/>
|
|
579
|
+
<MainMenu.DefaultItems.Export/>
|
|
580
|
+
</MainMenu.Group>
|
|
581
|
+
<MainMenu.Group title="custom items">
|
|
582
|
+
<MainMenu.Item onSelect={() => window.alert("Item1")}> Item1 </MainMenu.Item>
|
|
583
|
+
<MainMenu.Item onSelect={() => window.alert("Item2")}> Item 2 </>
|
|
584
|
+
</MainMenu.Group>
|
|
585
|
+
</MainMenu>
|
|
586
|
+
</Excalidraw>
|
|
587
|
+
}
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
| Prop | Type | Required | Default | Description |
|
|
591
|
+
| --- | --- | --- | --- | --- |
|
|
592
|
+
| `children ` | `React.ReactNode` | Yes | `undefined` | The content of the `Menu Group` |
|
|
593
|
+
| `title` | `string` | No | `undefined` | The `title` for the grouped items |
|
|
594
|
+
| `className` | `string` | No | "" | The `classname` to be added to the group |
|
|
595
|
+
| `style` | `React.CSsSProperties` | No | `undefined` | The inline `styles` to be added to the group |
|
|
596
|
+
|
|
408
597
|
### Props
|
|
409
598
|
|
|
410
599
|
| Name | Type | Default | Description |
|
|
@@ -1369,6 +1558,53 @@ viewportCoordsToSceneCoords({clientX: number, clientY: number}, appState: <a hre
|
|
|
1369
1558
|
|
|
1370
1559
|
This function returns equivalent scene coords for the provided viewport coords in params.
|
|
1371
1560
|
|
|
1561
|
+
#### useDevice
|
|
1562
|
+
|
|
1563
|
+
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
|
|
1564
|
+
|
|
1565
|
+
```js
|
|
1566
|
+
import { useDevice, Footer } from "@excalidraw/excalidraw";
|
|
1567
|
+
|
|
1568
|
+
const MobileFooter = ({
|
|
1569
|
+
}) => {
|
|
1570
|
+
const device = useDevice();
|
|
1571
|
+
if (device.isMobile) {
|
|
1572
|
+
return (
|
|
1573
|
+
<Footer>
|
|
1574
|
+
<button
|
|
1575
|
+
className="custom-footer"
|
|
1576
|
+
onClick={() => alert("This is custom footer in mobile menu")}
|
|
1577
|
+
>
|
|
1578
|
+
{" "}
|
|
1579
|
+
custom footer{" "}
|
|
1580
|
+
</button>
|
|
1581
|
+
</Footer>
|
|
1582
|
+
);
|
|
1583
|
+
}
|
|
1584
|
+
return null;
|
|
1585
|
+
|
|
1586
|
+
};
|
|
1587
|
+
const App = () => {
|
|
1588
|
+
<Excalidraw>
|
|
1589
|
+
<MainMenu>
|
|
1590
|
+
<MainMenu.Item> Item1 </MainMenu.Item>
|
|
1591
|
+
<MainMenu.Item> Item 2 </>
|
|
1592
|
+
<MobileFooter/>
|
|
1593
|
+
</MainMenu>
|
|
1594
|
+
</Excalidraw>
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
```
|
|
1598
|
+
|
|
1599
|
+
The `device` has the following `attributes`
|
|
1600
|
+
|
|
1601
|
+
| Name | Type | Description |
|
|
1602
|
+
| --- | --- | --- |
|
|
1603
|
+
| `isSmScreen` | `boolean` | Set to `true` when the device small screen is small (Width < `640px` ) |
|
|
1604
|
+
| `isMobile` | `boolean` | Set to `true` when the device is `mobile` |
|
|
1605
|
+
| `isTouchScreen` | `boolean` | Set to `true` for `touch` devices |
|
|
1606
|
+
| `canDeviceFitSidebar` | `boolean` | Implies whether there is enough space to fit the `sidebar` |
|
|
1607
|
+
|
|
1372
1608
|
### Exported constants
|
|
1373
1609
|
|
|
1374
1610
|
#### `FONT_FAMILY`
|