@ -24,6 +24,10 @@ By default it will try to load the files from `https://unpkg.com/@excalidraw/exc
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.
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.
#### Note
**If you don't want to wait for the next stable release and try out the unreleased changes you can use [@excalidraw/excalidraw-next](https://www.npmjs.com/package/@excalidraw/excalidraw-next).**
**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.**
For stable release please use [@excalidraw/excalidraw](https://www.npmjs.com/package/@excalidraw/excalidraw).
<!-- stable-readme-end-->
### Excalidraw
### Excalidraw
Excalidraw exported as a component to directly embed in your projects.
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.
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.
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.
Move the folder `excalidraw-assets` and `excalidraw-assets-dev` to the path where your assets are served.
Move the folder `excalidraw-assets` and `excalidraw-assets-dev` to the path where your assets are served.
By default it will try to load the files from `https://unpkg.com/@excalidraw/excalidraw/{currentVersion}/dist/`
By default it will try to load the files from `https://unpkg.com/@excalidraw/excalidraw-next/dist/`
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.
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.
@ -38,7 +48,7 @@ If you are using a Web bundler (for instance, Webpack), you can import it as an
```js
```js
import React, { useEffect, useState, useRef } from "react";
import React, { useEffect, useState, useRef } from "react";
import Excalidraw from "@excalidraw/excalidraw";
import Excalidraw from "@excalidraw/excalidraw-next";
The `types` are available at `@excalidraw/excalidraw/types`, you can view [example for typescript](https://codesandbox.io/s/excalidraw-types-9h2dm)
The `types` are available at `@excalidraw/excalidraw-next/types`, you can view [example for typescript](https://codesandbox.io/s/excalidraw-types-9h2dm)
#### In Browser
#### In Browser
@ -173,7 +183,7 @@ For development use :point_down:
@ -495,7 +505,7 @@ This callback is triggered when the shareable-link button is clicked in the expo
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.
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.
```js
```js
import { defaultLang, languages } from "@excalidraw/excalidraw";
import { defaultLang, languages } from "@excalidraw/excalidraw-next";
```
```
| name | type |
| name | type |
@ -636,7 +646,7 @@ The unique id of the excalidraw component. This can be used to identify the exca
**How to use**
**How to use**
<pre>
<pre>
import { getSceneVersion } from "@excalidraw/excalidraw";
import { getSceneVersion } from "@excalidraw/excalidraw-next";
import { restoreAppState } from "@excalidraw/excalidraw";
import { restoreAppState } from "@excalidraw/excalidraw-next";
```
```
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.
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.
import { restore } from "@excalidraw/excalidraw-next";
```
```
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)
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`
**How to use**
**How to use**
```js
```js
import { exportToCanvas } from "@excalidraw/excalidraw";
import { exportToCanvas } from "@excalidraw/excalidraw-next";
```
```
This function returns the canvas with the exported elements, appState and dimensions.
This function returns the canvas with the exported elements, appState and dimensions.
@ -786,7 +796,7 @@ exportToBlob(
**How to use**
**How to use**
```js
```js
import { exportToBlob } from "@excalidraw/excalidraw";
import { exportToBlob } from "@excalidraw/excalidraw-next";
```
```
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).
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).