|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+<!-- stable-readme-start-->
|
|
|
2
|
+
|
|
|
3
|
+## Note
|
|
|
4
|
+
|
|
|
5
|
+**This is an unstable release and not recommended for production. If you don't want to wait for the stable release and try out the unreleased changes you can use this.**
|
|
|
6
|
+
|
|
|
7
|
+For stable release please use [@excalidraw/excalidraw](https://www.npmjs.com/package/@excalidraw/excalidraw).
|
|
|
8
|
+
|
|
|
9
|
+<!-- stable-readme-end-->
|
|
|
10
|
+
|
|
1
|
11
|
### Excalidraw
|
|
2
|
12
|
|
|
3
|
13
|
Excalidraw exported as a component to directly embed in your projects.
|
|
|
@@ -7,20 +17,20 @@ Excalidraw exported as a component to directly embed in your projects.
|
|
7
|
17
|
You can use npm
|
|
8
|
18
|
|
|
9
|
19
|
```
|
|
10
|
|
-npm install react react-dom @excalidraw/excalidraw
|
|
|
20
|
+npm install react react-dom @excalidraw/excalidraw-next
|
|
11
|
21
|
```
|
|
12
|
22
|
|
|
13
|
23
|
or via yarn
|
|
14
|
24
|
|
|
15
|
25
|
```
|
|
16
|
|
-yarn add react react-dom @excalidraw/excalidraw
|
|
|
26
|
+yarn add react react-dom @excalidraw/excalidraw-next
|
|
17
|
27
|
```
|
|
18
|
28
|
|
|
19
|
29
|
After installation you will see a folder `excalidraw-assets` and `excalidraw-assets-dev` in `dist` directory which contains the assets needed for this app in prod and dev mode respectively.
|
|
20
|
30
|
|
|
21
|
31
|
Move the folder `excalidraw-assets` and `excalidraw-assets-dev` to the path where your assets are served.
|
|
22
|
32
|
|
|
23
|
|
-By default it will try to load the files from `https://unpkg.com/@excalidraw/excalidraw/{currentVersion}/dist/`
|
|
|
33
|
+By default it will try to load the files from `https://unpkg.com/@excalidraw/excalidraw-next/dist/`
|
|
24
|
34
|
|
|
25
|
35
|
If you want to load assets from a different path you can set a variable `window.EXCALIDRAW_ASSET_PATH` depending on environment (for example if you have different URL's for dev and prod) to the url from where you want to load the assets.
|
|
26
|
36
|
|
|
|
@@ -38,7 +48,7 @@ If you are using a Web bundler (for instance, Webpack), you can import it as an
|
|
38
|
48
|
|
|
39
|
49
|
```js
|
|
40
|
50
|
import React, { useEffect, useState, useRef } from "react";
|
|
41
|
|
-import Excalidraw from "@excalidraw/excalidraw";
|
|
|
51
|
+import Excalidraw from "@excalidraw/excalidraw-next";
|
|
42
|
52
|
import InitialData from "./initialData";
|
|
43
|
53
|
|
|
44
|
54
|
import "./styles.scss";
|
|
|
@@ -156,13 +166,13 @@ import { useState, useEffect } from "react";
|
|
156
|
166
|
export default function IndexPage() {
|
|
157
|
167
|
const [Comp, setComp] = useState(null);
|
|
158
|
168
|
useEffect(() => {
|
|
159
|
|
- import("@excalidraw/excalidraw").then((comp) => setComp(comp.default));
|
|
|
169
|
+ import("@excalidraw/excalidraw-next").then((comp) => setComp(comp.default));
|
|
160
|
170
|
});
|
|
161
|
171
|
return <>{Comp && <Comp />}</>;
|
|
162
|
172
|
}
|
|
163
|
173
|
```
|
|
164
|
174
|
|
|
165
|
|
-The `types` are available at `@excalidraw/excalidraw/types`, you can view [example for typescript](https://codesandbox.io/s/excalidraw-types-9h2dm)
|
|
|
175
|
+The `types` are available at `@excalidraw/excalidraw-next/types`, you can view [example for typescript](https://codesandbox.io/s/excalidraw-types-9h2dm)
|
|
166
|
176
|
|
|
167
|
177
|
#### In Browser
|
|
168
|
178
|
|
|
|
@@ -173,7 +183,7 @@ For development use :point_down:
|
|
173
|
183
|
```js
|
|
174
|
184
|
<script
|
|
175
|
185
|
type="text/javascript"
|
|
176
|
|
- src="https://unpkg.com/@excalidraw/excalidraw@0.8.0/dist/excalidraw.development.js"
|
|
|
186
|
+ src="https://unpkg.com/@excalidraw/excalidraw-next/dist/excalidraw.development.js"
|
|
177
|
187
|
></script>
|
|
178
|
188
|
```
|
|
179
|
189
|
|
|
|
@@ -182,7 +192,7 @@ For production use :point_down:
|
|
182
|
192
|
```js
|
|
183
|
193
|
<script
|
|
184
|
194
|
type="text/javascript"
|
|
185
|
|
- src="https://unpkg.com/@excalidraw/excalidraw@0.8.0/dist/excalidraw.production.min.js"
|
|
|
195
|
+ src="https://unpkg.com/@excalidraw/excalidraw-next/dist/excalidraw.production.min.js"
|
|
186
|
196
|
></script>
|
|
187
|
197
|
```
|
|
188
|
198
|
|
|
|
@@ -201,7 +211,7 @@ You will need to make sure `react`, `react-dom` is available as shown in the bel
|
|
201
|
211
|
|
|
202
|
212
|
<script
|
|
203
|
213
|
type="text/javascript"
|
|
204
|
|
- src="https://unpkg.com/@excalidraw/excalidraw@0.8.0/dist/excalidraw.development.js"
|
|
|
214
|
+ src="https://unpkg.com/@excalidraw/excalidraw-next/dist/excalidraw.development.js"
|
|
205
|
215
|
></script>
|
|
206
|
216
|
</head>
|
|
207
|
217
|
|
|
|
@@ -495,7 +505,7 @@ This callback is triggered when the shareable-link button is clicked in the expo
|
|
495
|
505
|
Determines the language of the UI. It should be one of the [available language codes](https://github.com/excalidraw/excalidraw/blob/master/src/i18n.ts#L14). Defaults to `en` (English). We also export default language and supported languages which you can import as shown below.
|
|
496
|
506
|
|
|
497
|
507
|
```js
|
|
498
|
|
-import { defaultLang, languages } from "@excalidraw/excalidraw";
|
|
|
508
|
+import { defaultLang, languages } from "@excalidraw/excalidraw-next";
|
|
499
|
509
|
```
|
|
500
|
510
|
|
|
501
|
511
|
| name | type |
|
|
|
@@ -636,7 +646,7 @@ The unique id of the excalidraw component. This can be used to identify the exca
|
|
636
|
646
|
**How to use**
|
|
637
|
647
|
|
|
638
|
648
|
<pre>
|
|
639
|
|
-import { getSceneVersion } from "@excalidraw/excalidraw";
|
|
|
649
|
+import { getSceneVersion } from "@excalidraw/excalidraw-next";
|
|
640
|
650
|
getSceneVersion(elements: <a href="https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L78">ExcalidrawElement[]</a>)
|
|
641
|
651
|
</pre>
|
|
642
|
652
|
|
|
|
@@ -653,7 +663,7 @@ isInvisiblySmallElement(element: <a href="https://github.com/excalidraw/excalid
|
|
653
|
663
|
**How to use**
|
|
654
|
664
|
|
|
655
|
665
|
```js
|
|
656
|
|
-import { isInvisiblySmallElement } from "@excalidraw/excalidraw";
|
|
|
666
|
+import { isInvisiblySmallElement } from "@excalidraw/excalidraw-next";
|
|
657
|
667
|
```
|
|
658
|
668
|
|
|
659
|
669
|
Returns `true` if element is invisibly small (e.g. width & height are zero).
|
|
|
@@ -669,7 +679,7 @@ getElementsMap(elements: <a href="https://github.com/excalidraw/excalidraw/blob
|
|
669
|
679
|
**How to use**
|
|
670
|
680
|
|
|
671
|
681
|
```js
|
|
672
|
|
-import { getElementsMap } from "@excalidraw/excalidraw";
|
|
|
682
|
+import { getElementsMap } from "@excalidraw/excalidraw-next";
|
|
673
|
683
|
```
|
|
674
|
684
|
|
|
675
|
685
|
This function returns an object where each element is mapped to its id.
|
|
|
@@ -687,7 +697,7 @@ restoreAppState(appState: <a href="https://github.com/excalidraw/excalidraw/blo
|
|
687
|
697
|
**_How to use_**
|
|
688
|
698
|
|
|
689
|
699
|
```js
|
|
690
|
|
-import { restoreAppState } from "@excalidraw/excalidraw";
|
|
|
700
|
+import { restoreAppState } from "@excalidraw/excalidraw-next";
|
|
691
|
701
|
```
|
|
692
|
702
|
|
|
693
|
703
|
This function will make sure all the keys have appropriate values in [appState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L42) and if any key is missing, it will be set to default value. If you pass `localAppState`, `localAppState` value will be preferred over the `appState` passed in params.
|
|
|
@@ -703,7 +713,7 @@ restoreElements(elements: <a href="https://github.com/excalidraw/excalidraw/blo
|
|
703
|
713
|
**_How to use_**
|
|
704
|
714
|
|
|
705
|
715
|
```js
|
|
706
|
|
-import { restoreElements } from "@excalidraw/excalidraw";
|
|
|
716
|
+import { restoreElements } from "@excalidraw/excalidraw-next";
|
|
707
|
717
|
```
|
|
708
|
718
|
|
|
709
|
719
|
This function will make sure all properties of element is correctly set and if any attribute is missing, it will be set to default value.
|
|
|
@@ -719,7 +729,7 @@ restoreElements(data: <a href="https://github.com/excalidraw/excalidraw/blob/ma
|
|
719
|
729
|
**_How to use_**
|
|
720
|
730
|
|
|
721
|
731
|
```js
|
|
722
|
|
-import { restore } from "@excalidraw/excalidraw";
|
|
|
732
|
+import { restore } from "@excalidraw/excalidraw-next";
|
|
723
|
733
|
```
|
|
724
|
734
|
|
|
725
|
735
|
This function makes sure elements and state is set to appropriate values and set to default value if not present. It is combination of [restoreElements](#restoreElements) and [restoreAppState](#restoreAppState)
|
|
|
@@ -760,7 +770,7 @@ Takes the scene elements and state and returns a JSON string. Deleted `elements`
|
|
760
|
770
|
**How to use**
|
|
761
|
771
|
|
|
762
|
772
|
```js
|
|
763
|
|
-import { exportToCanvas } from "@excalidraw/excalidraw";
|
|
|
773
|
+import { exportToCanvas } from "@excalidraw/excalidraw-next";
|
|
764
|
774
|
```
|
|
765
|
775
|
|
|
766
|
776
|
This function returns the canvas with the exported elements, appState and dimensions.
|
|
|
@@ -786,7 +796,7 @@ exportToBlob(
|
|
786
|
796
|
**How to use**
|
|
787
|
797
|
|
|
788
|
798
|
```js
|
|
789
|
|
-import { exportToBlob } from "@excalidraw/excalidraw";
|
|
|
799
|
+import { exportToBlob } from "@excalidraw/excalidraw-next";
|
|
790
|
800
|
```
|
|
791
|
801
|
|
|
792
|
802
|
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).
|