@dwelle/excalidraw 0.3.41 → 0.3.45
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 +15 -14
- package/README_NEXT.md +34 -0
- package/dist/excalidraw.development.js +18 -18
- package/dist/excalidraw.production.min.js +1 -1
- package/package.json +9 -7
- package/types/actions/actionCanvas.d.ts +1 -1
- package/types/components/App.d.ts +2 -2
- package/types/components/ButtonIconSelect.d.ts +1 -0
- package/types/constants.d.ts +6 -5
- package/types/element/Hyperlink.d.ts +1 -1
- package/types/element/linearElementEditor.d.ts +1 -1
- package/types/keys.d.ts +1 -0
- package/types/renderer/renderElement.d.ts +11 -1
- package/types/types.d.ts +5 -3
- package/types/utils.d.ts +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -15,19 +15,20 @@ Please add the latest change on the top under the correct section.
|
|
|
15
15
|
|
|
16
16
|
## Excalidraw API
|
|
17
17
|
|
|
18
|
-
- [`exportToBlob`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#exportToBlob) now automatically sets `appState.exportBackground` to `true` if exporting to `image/jpeg` MIME type (to ensure that alpha channel is not compressed to black color).
|
|
19
|
-
|
|
20
18
|
### Features
|
|
21
19
|
|
|
20
|
+
- Add `onLinkOpen` prop which will be triggered when clicked on element hyperlink if present [#4694](https://github.com/excalidraw/excalidraw/pull/4694).
|
|
22
21
|
- Support updating library using [`updateScene`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#updateScene) API [#4546](https://github.com/excalidraw/excalidraw/pull/4546).
|
|
23
22
|
|
|
24
|
-
- Introduced primary colors to the app. The colors can be overriden. Check [readme](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#customizing-styles) on how to do so.
|
|
23
|
+
- Introduced primary colors to the app. The colors can be overriden. Check [readme](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#customizing-styles) on how to do so [#4387](https://github.com/excalidraw/excalidraw/pull/4387).
|
|
25
24
|
|
|
26
|
-
-
|
|
25
|
+
- [`exportToBlob`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#exportToBlob) now automatically sets `appState.exportBackground` to `true` if exporting to `image/jpeg` MIME type (to ensure that alpha channel is not compressed to black color) [#4342](https://github.com/excalidraw/excalidraw/pull/4342).
|
|
26
|
+
|
|
27
|
+
#### BREAKING CHANGE
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
Remove `getElementMap` util [#4306](https://github.com/excalidraw/excalidraw/pull/4306).
|
|
29
30
|
|
|
30
|
-
- Changes to [`exportToCanvas`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#exportToCanvas) util function:
|
|
31
|
+
- Changes to [`exportToCanvas`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#exportToCanvas) util function [#4321](https://github.com/excalidraw/excalidraw/pull/4321):
|
|
31
32
|
|
|
32
33
|
- Add `maxWidthOrHeight?: number` attribute.
|
|
33
34
|
- `scale` returned from `getDimensions()` is now optional (default to `1`).
|
|
@@ -56,11 +57,11 @@ Please add the latest change on the top under the correct section.
|
|
|
56
57
|
- `.excalidraw` files may now contain top-level `files` key in format of `Record<FileId, BinaryFileData>` when exporting any (image) elements.
|
|
57
58
|
- Changes were made to various export utilityies exported from the package so that they take `files`. For now, TypeScript should help you figure the changes out.
|
|
58
59
|
|
|
59
|
-
- Export [`isLinearElement`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#isLinearElement) and [`getNonDeletedElements`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#getNonDeletedElements).
|
|
60
|
+
- Export [`isLinearElement`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#isLinearElement) and [`getNonDeletedElements`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#getNonDeletedElements) [#4072](https://github.com/excalidraw/excalidraw/pull/4072).
|
|
60
61
|
|
|
61
|
-
- Support [`renderTopRightUI`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#renderTopRightUI) in mobile UI.
|
|
62
|
+
- Support [`renderTopRightUI`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#renderTopRightUI) in mobile UI [#4065](https://github.com/excalidraw/excalidraw/pull/4065).
|
|
62
63
|
|
|
63
|
-
- Export `THEME` constant from the package so host can use this when passing the theme.
|
|
64
|
+
- Export `THEME` constant from the package so host can use this when passing the theme [#4055](https://github.com/excalidraw/excalidraw/pull/4055).
|
|
64
65
|
|
|
65
66
|
#### BREAKING CHANGE
|
|
66
67
|
|
|
@@ -70,15 +71,15 @@ Please add the latest change on the top under the correct section.
|
|
|
70
71
|
|
|
71
72
|
- Reset `unmounted` state on the component once component mounts to fix the mounting/unmounting repeatedly when used with `useEffect` [#4682](https://github.com/excalidraw/excalidraw/pull/4682).
|
|
72
73
|
- Panning the canvas using `mousewheel-drag` and `space-drag` now prevents the browser from scrolling the container/page [#4489](https://github.com/excalidraw/excalidraw/pull/4489).
|
|
73
|
-
- Scope drag and drop events to Excalidraw container to prevent overriding host application drag and drop events.
|
|
74
|
+
- Scope drag and drop events to Excalidraw container to prevent overriding host application drag and drop events [#4445](https://github.com/excalidraw/excalidraw/pull/4445).
|
|
74
75
|
|
|
75
76
|
### Build
|
|
76
77
|
|
|
77
|
-
- Added an example to test and develop the package [locally](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#Development) using `yarn start`
|
|
78
|
+
- Added an example to test and develop the package [locally](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#Development) using `yarn start` [#4488](https://github.com/excalidraw/excalidraw/pull/4488)
|
|
78
79
|
|
|
79
|
-
- Remove `file-loader` so font assets are not duplicated by webpack and use webpack asset modules for font generation [#4380](https://github.com/excalidraw/excalidraw/pull/4380)
|
|
80
|
+
- Remove `file-loader` so font assets are not duplicated by webpack and use webpack asset modules for font generation [#4380](https://github.com/excalidraw/excalidraw/pull/4380).
|
|
80
81
|
|
|
81
|
-
- We're now compiling to `es2017` target. Notably, `async/await` is not compiled down to generators. [#4341](https://github.com/excalidraw/excalidraw/pull/4341)
|
|
82
|
+
- We're now compiling to `es2017` target. Notably, `async/await` is not compiled down to generators. [#4341](https://github.com/excalidraw/excalidraw/pull/4341).
|
|
82
83
|
|
|
83
84
|
---
|
|
84
85
|
|
|
@@ -88,7 +89,7 @@ Please add the latest change on the top under the correct section.
|
|
|
88
89
|
|
|
89
90
|
### Fixes
|
|
90
91
|
|
|
91
|
-
- Don't show save file to disk button in export dialog when `saveFileToDisk` passed as `false` in [`UIOptions.canvasActions.export`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#exportOpts).
|
|
92
|
+
- Don't show save file to disk button in export dialog when `saveFileToDisk` passed as `false` in [`UIOptions.canvasActions.export`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#exportOpts) [#4073](https://github.com/excalidraw/excalidraw/pull/4073).
|
|
92
93
|
|
|
93
94
|
- [`onPaste`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#onPaste) prop should return false to prevent the native excalidraw paste action [#3974](https://github.com/excalidraw/excalidraw/pull/3974).
|
|
94
95
|
|
package/README_NEXT.md
CHANGED
|
@@ -405,6 +405,7 @@ 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#L78">NonDeletedExcalidrawElement</a>, event: CustomEvent) </pre> | | This prop if passed will be triggered when link of an element is clicked |
|
|
408
409
|
|
|
409
410
|
### Dimensions of Excalidraw
|
|
410
411
|
|
|
@@ -704,6 +705,39 @@ Allows you to override `id` generation for files added on canvas (images). By de
|
|
|
704
705
|
(file: File) => string | Promise<string>
|
|
705
706
|
```
|
|
706
707
|
|
|
708
|
+
#### `onLinkOpen`
|
|
709
|
+
|
|
710
|
+
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()`.
|
|
711
|
+
|
|
712
|
+
```
|
|
713
|
+
(element: ExcalidrawElement, event: CustomEvent<{ nativeEvent: MouseEvent }>) => void
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
Example:
|
|
717
|
+
|
|
718
|
+
```ts
|
|
719
|
+
const history = useHistory();
|
|
720
|
+
|
|
721
|
+
// open internal links using the app's router, but opens external links in
|
|
722
|
+
// a new tab/window
|
|
723
|
+
const onLinkOpen: ExcalidrawProps["onLinkOpen"] = useCallback(
|
|
724
|
+
(element, event) => {
|
|
725
|
+
const link = element.link;
|
|
726
|
+
const { nativeEvent } = event.detail;
|
|
727
|
+
const isNewTab = nativeEvent.ctrlKey || nativeEvent.metaKey;
|
|
728
|
+
const isNewWindow = nativeEvent.shiftKey;
|
|
729
|
+
const isInternalLink =
|
|
730
|
+
link.startsWith("/") || link.includes(window.location.origin);
|
|
731
|
+
if (isInternalLink && !isNewTab && !isNewWindow) {
|
|
732
|
+
history.push(link.replace(window.location.origin, ""));
|
|
733
|
+
// signal that we're handling the redirect ourselves
|
|
734
|
+
event.preventDefault();
|
|
735
|
+
}
|
|
736
|
+
},
|
|
737
|
+
[history],
|
|
738
|
+
);
|
|
739
|
+
```
|
|
740
|
+
|
|
707
741
|
### Does it support collaboration ?
|
|
708
742
|
|
|
709
743
|
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).
|