diff --git a/.codesandbox/tasks.json b/.codesandbox/tasks.json
new file mode 100644
index 000000000..360636c4c
--- /dev/null
+++ b/.codesandbox/tasks.json
@@ -0,0 +1,43 @@
+{
+ // These tasks will run in order when initializing your CodeSandbox project.
+ "setupTasks": [
+ {
+ "name": "Install Dependencies",
+ "command": "yarn install"
+ }
+ ],
+
+ // These tasks can be run from CodeSandbox. Running one will open a log in the app.
+ "tasks": {
+ "build": {
+ "name": "Build",
+ "command": "yarn build",
+ "runAtStart": false
+ },
+ "fix": {
+ "name": "Fix",
+ "command": "yarn fix",
+ "runAtStart": false
+ },
+ "prettier": {
+ "name": "Prettify",
+ "command": "yarn prettier",
+ "runAtStart": false
+ },
+ "start": {
+ "name": "Start Excalidraw",
+ "command": "yarn start",
+ "runAtStart": true
+ },
+ "test": {
+ "name": "Run Tests",
+ "command": "yarn test",
+ "runAtStart": false
+ },
+ "install-deps": {
+ "name": "Install Dependencies",
+ "command": "yarn install",
+ "restartOn": { "files": ["yarn.lock"] }
+ }
+ }
+}
diff --git a/.dockerignore b/.dockerignore
index 9f12280ed..7a0150947 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,5 +1,6 @@
*
-!.env
+!.env.development
+!.env.production
!.eslintrc.json
!.npmrc
!.prettierrc
diff --git a/.env.development b/.env.development
index 1a5fbda3f..0c2fb5527 100644
--- a/.env.development
+++ b/.env.development
@@ -20,3 +20,15 @@ REACT_APP_DEV_ENABLE_SW=
# whether to disable live reload / HMR. Usuaully what you want to do when
# debugging Service Workers.
REACT_APP_DEV_DISABLE_LIVE_RELOAD=
+
+FAST_REFRESH=false
+
+# MATOMO
+REACT_APP_MATOMO_URL=
+REACT_APP_CDN_MATOMO_TRACKER_URL=
+REACT_APP_MATOMO_SITE_ID=
+
+#Debug flags
+
+# To enable bounding box for text containers
+REACT_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX=
diff --git a/.env.production b/.env.production
index 183db7ea2..8737c63c7 100644
--- a/.env.production
+++ b/.env.production
@@ -12,6 +12,13 @@ REACT_APP_WS_SERVER_URL=
REACT_APP_FIREBASE_CONFIG='{"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}'
# production-only vars
+# GOOGLE ANALYTICS
REACT_APP_GOOGLE_ANALYTICS_ID=UA-387204-13
+# MATOMO
+REACT_APP_MATOMO_URL=https://excalidraw.matomo.cloud/
+REACT_APP_CDN_MATOMO_TRACKER_URL=//cdn.matomo.cloud/excalidraw.matomo.cloud/matomo.js
+REACT_APP_MATOMO_SITE_ID=1
+
+
REACT_APP_PLUS_APP=https://app.excalidraw.com
diff --git a/.github/workflows/autorelease-excalidraw.yml b/.github/workflows/autorelease-excalidraw.yml
index 24071b3a2..ad0a0a7e9 100644
--- a/.github/workflows/autorelease-excalidraw.yml
+++ b/.github/workflows/autorelease-excalidraw.yml
@@ -2,7 +2,7 @@ name: Auto release excalidraw next
on:
push:
branches:
- - master
+ - release
jobs:
Auto-release-excalidraw-next:
diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml
index d767a3335..f5f9b45bb 100644
--- a/.github/workflows/build-docker.yml
+++ b/.github/workflows/build-docker.yml
@@ -3,7 +3,7 @@ name: Build Docker image
on:
push:
branches:
- - master
+ - release
jobs:
build-docker:
diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml
index 13f6c73c9..e1ef21665 100644
--- a/.github/workflows/cancel.yml
+++ b/.github/workflows/cancel.yml
@@ -3,7 +3,7 @@ name: Cancel previous runs
on:
push:
branches:
- - master
+ - release
pull_request:
jobs:
diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml
index 1ec35b8b8..a4a8a4c5f 100644
--- a/.github/workflows/publish-docker.yml
+++ b/.github/workflows/publish-docker.yml
@@ -3,7 +3,7 @@ name: Publish Docker
on:
push:
branches:
- - master
+ - release
jobs:
publish-docker:
diff --git a/.github/workflows/sentry-production.yml b/.github/workflows/sentry-production.yml
index 228b6f148..6f53f91eb 100644
--- a/.github/workflows/sentry-production.yml
+++ b/.github/workflows/sentry-production.yml
@@ -3,7 +3,7 @@ name: New Sentry production release
on:
push:
branches:
- - master
+ - release
jobs:
sentry:
diff --git a/.gitignore b/.gitignore
index 02630d924..e637a8c0f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,4 +25,4 @@ src/packages/excalidraw/types
src/packages/excalidraw/example/public/bundle.js
src/packages/excalidraw/example/public/excalidraw-assets-dev
src/packages/excalidraw/example/public/excalidraw.development.js
-
+coverage
diff --git a/.husky/pre-commit b/.husky/pre-commit
index 521508d8e..ab2a5ac5f 100755
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -1,2 +1,2 @@
#!/bin/sh
-yarn lint-staged
+# yarn lint-staged
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index b3a5c325c..509908e5d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,63 +1,3 @@
# Contributing
-## Setup
-
-### Option 1 - Manual
-
-1. Fork and clone the repo
-1. Run `yarn` to install dependencies
-1. Create a branch for your PR with `git checkout -b your-branch-name`
-
-> To keep `master` branch pointing to remote repository and make pull requests from branches on your fork. To do this, run:
->
-> ```sh
-> git remote add upstream https://github.com/excalidraw/excalidraw.git
-> git fetch upstream
-> git branch --set-upstream-to=upstream/master master
-> ```
-
-### Option 2 - CodeSandbox
-
-1. Go to https://codesandbox.io/s/github/excalidraw/excalidraw
-1. Connect your GitHub account
-1. Go to Git tab on left side
-1. Tap on `Fork Sandbox`
-1. Write your code
-1. Commit and PR automatically
-
-## Pull Request Guidelines
-
-Don't worry if you get any of the below wrong, or if you don't know how. We'll gladly help out.
-
-### Title
-
-Make sure the title starts with a semantic prefix:
-
-- **feat**: A new feature
-- **fix**: A bug fix
-- **docs**: Documentation only changes
-- **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
-- **refactor**: A code change that neither fixes a bug nor adds a feature
-- **perf**: A code change that improves performance
-- **test**: Adding missing tests or correcting existing tests
-- **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
-- **ci**: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
-- **chore**: Other changes that don't modify src or test files
-- **revert**: Reverts a previous commit
-
-### Changelog
-
-Add a brief description of your pull request to the changelog located here: [`src/packages/excalidraw/CHANGELOG.md`](src/packages/excalidraw/CHANGELOG.md)
-
-Notes:
-
-- Make sure to prepend to the section corresponding with the semantic prefix you selected in the title
-- Link to your pull request - this will require updating the CHANGELOG _after_ creating the pull request
-
-### Testing
-
-Once you submit your pull request it will automatically be tested. Be sure to check the results of the test and fix any issues that arise.
-
-It's also a good idea to consider if your change should include additional tests. This is highly recommended for new features or bug-fixes. For example, it's good practice to create a test for each bug you fix which ensures that we don't regress the code in the future.
-
-Finally - always manually test your changes using the convenient staging environment deployed for each pull request. As much as local development attempts to replicate production, there can still be subtle differences in behavior. For larger features consider testing your change in multiple browsers as well.
+Head over to the [docs](https://docs.excalidraw.com/docs/introduction/contributing)
diff --git a/Dockerfile b/Dockerfile
index f295f7f6a..d1fa424e5 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,7 +3,7 @@ FROM node:14-alpine AS build
WORKDIR /opt/node_app
COPY package.json yarn.lock ./
-RUN yarn --ignore-optional
+RUN yarn --ignore-optional --network-timeout 600000
ARG NODE_ENV=production
diff --git a/README.md b/README.md
index 51f706382..48529165e 100644
--- a/README.md
+++ b/README.md
@@ -1,201 +1,126 @@
-
+ Create beautiful hand-drawn like diagrams, wireframes, or whatever you like.
+
+
+
+
-Read the latest news and updates on our [blog](https://blog.excalidraw.com). A good start is to see all the updates of [One Year of Excalidraw](https://blog.excalidraw.com/one-year-of-excalidraw/).
+## Features
-## Supporting Excalidraw
+The Excalidraw editor (npm package) supports:
-If you like the project, you can become a sponsor at [Open Collective](https://opencollective.com/excalidraw).
+- 💯 Free & open-source.
+- 🎨 Infinite, canvas-based whiteboard.
+- ✍️ Hand-drawn like style.
+- 🌓 Dark mode.
+- 🏗️ Customizable.
+- 📷 Image support.
+- 😀 Shape libraries support.
+- 👅 Localization (i18n) support.
+- 🖼️ Export to PNG, SVG & clipboard.
+- 💾 Open format - export drawings as an `.excalidraw` json file.
+- ⚒️ Wide range of tools - rectangle, circle, diamond, arrow, line, free-draw, eraser...
+- ➡️ Arrow-binding & labeled arrows.
+- 🔙 Undo / Redo.
+- 🔍 Zoom and panning support.
-[](https://opencollective.com/excalidraw/tiers/sponsors/0/website) [](https://opencollective.com/excalidraw/tiers/sponsors/1/website) [](https://opencollective.com/excalidraw/tiers/sponsors/2/website) [](https://opencollective.com/excalidraw/tiers/sponsors/3/website) [](https://opencollective.com/excalidraw/tiers/sponsors/4/website) [](https://opencollective.com/excalidraw/tiers/sponsors/5/website) [](https://opencollective.com/excalidraw/tiers/sponsors/6/website) [](https://opencollective.com/excalidraw/tiers/sponsors/7/website) [](https://opencollective.com/excalidraw/tiers/sponsors/8/website) [](https://opencollective.com/excalidraw/tiers/sponsors/9/website) [](https://opencollective.com/excalidraw/tiers/sponsors/10/website)
+## Excalidraw.com
+
+The app hosted at [excalidraw.com](https://excalidraw.com) is a minimal showcase of what you can build with Excalidraw. Its [source code](https://github.com/excalidraw/excalidraw/tree/master/src/excalidraw-app) is part of this repository as well, and the app features:
+
+- 📡 PWA support (works offline).
+- 🤼 Real-time collaboration.
+- 🔒 End-to-end encryption.
+- 💾 Local-first support (autosaves to the browser).
+- 🔗 Shareable links (export to a readonly link you can share with others).
+
+We'll be adding these features as drop-in plugins for the npm package in the future.
+
+## Quick start
+
+Install the [Excalidraw npm package](https://www.npmjs.com/package/@excalidraw/excalidraw):
+
+```
+npm install react react-dom @excalidraw/excalidraw
+```
+
+or via yarn
+
+```
+yarn add react react-dom @excalidraw/excalidraw
+```
+
+Don't forget to check out our [Documentation](https://docs.excalidraw.com)!
+
+## Contributing
+
+- Missing something or found a bug? [Report here](https://github.com/excalidraw/excalidraw/issues).
+- Want to contribute? Check out our [contribution guide](https://docs.excalidraw.com/docs/introduction/contributing) or let us know on [Discord](https://discord.gg/UexuTaE).
+- Want to help with translations? See the [translation guide](https://docs.excalidraw.com/docs/introduction/contributing#translating).
+
+## Integrations
+
+- [VScode extension](https://marketplace.visualstudio.com/items?itemName=pomdtr.excalidraw-editor)
+- [npm package](https://www.npmjs.com/package/@excalidraw/excalidraw)
+
+## Who's integrating Excalidraw
+
+[Google Cloud](https://googlecloudcheatsheet.withgoogle.com/architecture) • [Meta](https://meta.com/) • [CodeSandbox](https://codesandbox.io/) • [Obsidian Excalidraw](https://github.com/zsviczian/obsidian-excalidraw-plugin) • [Replit](https://replit.com/) • [Slite](https://slite.com/) • [Notion](https://notion.so/) • [HackerRank](https://www.hackerrank.com/) • and many others
+
+## Sponsors & support
+
+If you like the project, you can become a sponsor at [Open Collective](https://opencollective.com/excalidraw) or use [Excalidraw+](https://plus.excalidraw.com/).
+
+## Thank you for supporting Excalidraw
+
+[](https://opencollective.com/excalidraw/tiers/sponsors/0/website) [](https://opencollective.com/excalidraw/tiers/sponsors/1/website) [](https://opencollective.com/excalidraw/tiers/sponsors/2/website) [](https://opencollective.com/excalidraw/tiers/sponsors/3/website) [](https://opencollective.com/excalidraw/tiers/sponsors/4/website) [](https://opencollective.com/excalidraw/tiers/sponsors/5/website) [](https://opencollective.com/excalidraw/tiers/sponsors/6/website) [](https://opencollective.com/excalidraw/tiers/sponsors/7/website) [](https://opencollective.com/excalidraw/tiers/sponsors/8/website) [](https://opencollective.com/excalidraw/tiers/sponsors/9/website) [](https://opencollective.com/excalidraw/tiers/sponsors/10/website)
Last but not least, we're thankful to these companies for offering their services for free:
[](https://vercel.com) [](https://sentry.io) [](https://crowdin.com)
-
-## Who's integrating Excalidraw
-
-[Google Cloud](https://googlecloudcheatsheet.withgoogle.com/architecture) • [Meta](https://meta.com/) • [CodeSandbox](https://codesandbox.io/) • [Obsidian Excalidraw](https://github.com/zsviczian/obsidian-excalidraw-plugin) • [Replit](https://replit.com/) • [Slite](https://slite.com/) • [Notion](https://notion.so/) • [HackerRank](https://www.hackerrank.com/) •
-
-## Documentation
-
-### Shortcuts
-
-You can almost do anything with shortcuts. Click on the help icon on the bottom right corner to see them all.
-
-### Curved lines and arrows
-
-Choose line or arrow and click click click instead of drag.
-
-### Charts
-
-You can easily create charts by copy pasting data from Excel or just plain comma separated text.
-
-### Translating
-
-To translate Excalidraw into other languages, please visit [our Crowdin page](https://crowdin.com/project/excalidraw). To add a new language, [open an issue](https://github.com/excalidraw/excalidraw/issues/new) so we can get things set up on our end first.
-
-Translations will be available on the app if they exceed a certain threshold of completion (currently 85%).
-
-### Create a collaboration session manually
-
-In order to create a session manually, you just need to generate a link of this form:
-
-```
-https://excalidraw.com/#room=[0-9a-f]{20},[a-zA-Z0-9_-]{22}
-```
-
-#### Example
-
-```
-https://excalidraw.com/#room=91bd46ae3aa84dff9d20,pfLqgEoY1c2ioq8LmGwsFA
-```
-
-The first set of digits is the room. This is visible from the server that’s going to dispatch messages to everyone that knows this number.
-
-The second set of digits is the encryption key. The Excalidraw server doesn’t know about it. This is what all the participants use to encrypt/decrypt the messages.
-
-> Note: Please ensure that the encryption key is 22 characters long.
-
-## Shape libraries
-
-Find a growing list of libraries containing assets for your drawings at [libraries.excalidraw.com](https://libraries.excalidraw.com).
-
-## Embedding Excalidraw in your App?
-
-Try out [`@excalidraw/excalidraw`](https://www.npmjs.com/package/@excalidraw/excalidraw). This package allows you to easily embed Excalidraw as a React component into your apps.
-
-## Development
-
-### Code Sandbox
-
-- Go to https://codesandbox.io/s/github/excalidraw/excalidraw
- - You may need to sign in with GitHub and reload the page
-- You can start coding instantly, and even send PRs from there!
-
-### Local Installation
-
-These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
-
-#### Requirements
-
-- [Node.js](https://nodejs.org/en/)
-- [Yarn](https://yarnpkg.com/getting-started/install) (v1 or v2.4.2+)
-- [Git](https://git-scm.com/downloads)
-
-#### Clone the repo
-
-```bash
-git clone https://github.com/excalidraw/excalidraw.git
-```
-
-#### Install the dependencies
-
-```bash
-yarn
-```
-
-#### Start the server
-
-```bash
-yarn start
-```
-
-Now you can open [http://localhost:3000](http://localhost:3000) and start coding in your favorite code editor.
-
-#### Collaboration
-
-For collaboration, you will need to set up [collab server](https://github.com/excalidraw/excalidraw-room) in local.
-
-#### Commands
-
-##### Install the dependencies
-
-```
-yarn
-```
-
-##### Run the project
-
-```
-yarn start
-```
-
-##### Reformat all files with Prettier
-
-```
-yarn fix
-```
-
-##### Run tests
-
-```
-yarn test
-```
-
-##### Update test snapshots
-
-```
-yarn test:update
-```
-
-##### Test for formatting with Prettier
-
-```
-yarn test:code
-```
-
-#### Docker Compose
-
-You can use docker-compose to work on Excalidraw locally if you don't want to setup a Node.js env.
-
-```sh
-docker-compose up --build -d
-```
-
-### Self-hosting
-
-We publish a Docker image with the Excalidraw client at [excalidraw/excalidraw](https://hub.docker.com/r/excalidraw/excalidraw). You can use it to self-host your own client under your own domain, on Kubernetes, AWS ECS, etc.
-
-```sh
-docker build -t excalidraw/excalidraw .
-docker run --rm -dit --name excalidraw -p 5000:80 excalidraw/excalidraw:latest
-```
-
-The Docker image is free of analytics and other tracking libraries.
-
-**At the moment, self-hosting your own instance doesn't support sharing or collaboration features.**
-
-We are working towards providing a full-fledged solution for self-hosting your own Excalidraw.
-
-## Contributing
-
-Pull requests are welcome. For major changes, please [open an issue](https://github.com/excalidraw/excalidraw/issues/new) first to discuss what you would like to change.
-
-## Notable used tools
-
-- [Create React App](https://github.com/facebook/create-react-app)
-- [Rough.js](https://roughjs.com)
-- [TypeScript](https://www.typescriptlang.org)
-- [Vercel](https://vercel.com)
-
-And the main source of inspiration for starting the project is the awesome [Zwibbler](https://zwibbler.com/demo/) app.
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/api-intro.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/api-intro.mdx
new file mode 100644
index 000000000..aee7f3bfb
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/api-intro.mdx
@@ -0,0 +1,11 @@
+---
+slug: /@excalidraw/excalidraw/api
+---
+
+# API
+
+Currently the **API** is divided into 3 broad categories 👇
+
+- [Props](/docs/@excalidraw/excalidraw/api/props) - The `props` you can pass to the `Excalidraw` component.
+- [Children components](/docs/@excalidraw/excalidraw/api/children-components) - Official components you can use to customize the UI.
+- [Utils](/docs/@excalidraw/excalidraw/api/utils) - Utilities and helpers you can use to export, restore and more.
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/children-components/children-components-intro.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/children-components/children-components-intro.mdx
new file mode 100644
index 000000000..706adb594
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/children-components/children-components-intro.mdx
@@ -0,0 +1,21 @@
+---
+sidebar_label: Children Components
+slug: /@excalidraw/excalidraw/api/children-components
+---
+
+# `` children
+
+We expose several components you can render as children of the `` component to customize the UI.
+
+:::info
+
+We have only recently started migrating to this type of component API. Some UI components are still using render props, and some UI customization isn't supported yet (such as the toolbar or the element properties panel). Stay tuned for more updates!
+
+:::
+
+Below are the currently supported components:
+
+- [MainMenu](/docs/@excalidraw/excalidraw/api/children-components/main-menu)
+- [WelcomeScreen](/docs/@excalidraw/excalidraw/api/children-components/welcome-screen)
+- [Footer](/docs/@excalidraw/excalidraw/api/children-components/footer)
+- [LiveCollaborationTrigger](/docs/@excalidraw/excalidraw/api/children-components/live-collaboration-trigger)
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/children-components/footer.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/children-components/footer.mdx
new file mode 100644
index 000000000..262681895
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/children-components/footer.mdx
@@ -0,0 +1,69 @@
+# Footer
+
+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.
+
+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.
+
+**Usage**
+
+```jsx live
+function App() {
+ return (
+
+
+
+
+
+ );
+}
+```
+
+This will only for `Desktop` devices.
+
+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.
+
+Open the `Menu` in the below playground and you will see the `custom footer` rendered.
+
+```jsx live noInline
+const MobileFooter = ({}) => {
+ const device = useDevice();
+ if (device.isMobile) {
+ return (
+
+ );
+ }
+ return null;
+};
+
+const App = () => (
+
+
+
+ Item1
+ Item 2
+
+
+
+
+);
+
+// Need to render when code is span across multiple components
+// in Live Code blocks editor
+render();
+```
\ No newline at end of file
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/children-components/live-collaboration-trigger.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/children-components/live-collaboration-trigger.mdx
new file mode 100644
index 000000000..ef74d0e65
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/children-components/live-collaboration-trigger.mdx
@@ -0,0 +1,62 @@
+# LiveCollaborationTrigger
+
+If you implement live collaboration support and want to expose the same UI button as on [excalidraw.com](https://excalidraw.com), you can render the `` component using the [renderTopRightUI](/docs/@excalidraw/excalidraw/api/props#rendertoprightui) prop.
+
+You'll need to supply `onSelect()` to handle opening of your collaboration dialog, but the button will display `appState.collaborators` count provided you have supplied it.
+
+| Prop | Type | Required | Default | Description |
+| --- | --- | --- | --- | --- |
+| `onSelect` | `function` | Yes | | Handler called when the user clicks on the button |
+| `isCollaborating` | `boolean` | Yes | false | Whether live collaboration session is in effect. Modifies button style. |
+
+```tsx live
+function App() {
+ const [excalidrawAPI, setExcalidrawAPI] = useState(null);
+ const [isCollaborating, setIsCollaborating] = useState(false);
+ return (
+
+
+ Selecting the checkbox to see the collaborator count
+
+ );
+}
+```
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/children-components/main-menu.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/children-components/main-menu.mdx
new file mode 100644
index 000000000..8fbf228df
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/children-components/main-menu.mdx
@@ -0,0 +1,169 @@
+# MainMenu
+
+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.
+
+**Usage**
+
+```jsx live
+function App() {
+ return (
+
+ );
+}
+```
+
+### ``
+
+This is the `MainMenu` component. If you render it, you will need to populate the menu with your own items as we will not render any ourselves at that point.
+
+| Prop | Type | Required | Default | Description |
+| --- | --- | :-: | :-: | --- |
+| `onSelect` | `function` | No | - | Triggered when any item is selected (via mouse). Calling `event.preventDefault()` will stop menu from closing. |
+
+### MainMenu.Item
+
+To render an item, its recommended to use `MainMenu.Item`.
+
+| Prop | Type | Required | Default | Description |
+| --- | --- | :-: | :-: | --- |
+| `onSelect` | `function` | Yes | - | Triggered when selected (via mouse). Calling `event.preventDefault()` will stop menu from closing. |
+| `children` | `React.ReactNode` | Yes | - | The content of the menu item |
+| `icon` | `JSX.Element` | No | - | The icon used in the menu item |
+| `shortcut` | `string` | No | - | The shortcut to be shown for the menu item |
+
+### MainMenu.ItemLink
+
+To render an item as a link, its recommended to use `MainMenu.ItemLink`.
+
+**Usage**
+
+```jsx live
+function App() {
+ return (
+
+
+
+
+ Google
+
+
+ Excalidraw
+
+
+
+
+ );
+}
+```
+
+| Prop | Type | Required | Default | Description |
+| --- | --- | :-: | :-: | --- |
+| `onSelect` | `function` | No | - | Triggered when selected (via mouse). Calling `event.preventDefault()` will stop menu from closing. |
+| `href` | `string` | Yes | - | The `href` attribute to be added to the `anchor` element. |
+| `children` | `React.ReactNode` | Yes | - | The content of the menu item |
+| `icon` | `JSX.Element` | No | - | The icon used in the menu item |
+| `shortcut` | `string` | No | - | The shortcut to be shown for the menu item |
+
+### MainMenu.ItemCustom
+
+To render a custom item, you can use `MainMenu.ItemCustom`.
+
+**Usage**
+
+```jsx live
+function App() {
+ return (
+
+
+
+
+
+
+
+
+
+ );
+}
+```
+
+| Prop | Type | Required | Default | Description |
+| --- | --- | :-: | :-: | --- |
+| `children` | `React.ReactNode` | Yes | - | The content of the menu item |
+
+### MainMenu.DefaultItems
+
+For the items which are shown in the menu in [excalidraw.com](https://excalidraw.com), you can use `MainMenu.DefaultItems`
+
+```jsx live
+function App() {
+ return (
+
+ );
+}
+```
+
+Here is a [complete list](https://github.com/excalidraw/excalidraw/blob/master/src/components/mainMenu/DefaultItems.tsx) of the default items.
+
+### MainMenu.Group
+
+To Group item in the main menu, you can use `MainMenu.Group`
+
+```jsx live
+function App() {
+ return (
+
+ );
+}
+```
+
+| Prop | Type | Required | Default | Description |
+| --- | --- | :-: | :-: | --- |
+| `children ` | `React.ReactNode` | Yes | - | The content of the `Menu Group` |
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/children-components/welcome-screen.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/children-components/welcome-screen.mdx
new file mode 100644
index 000000000..8150508bf
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/children-components/welcome-screen.mdx
@@ -0,0 +1,140 @@
+# WelcomeScreen
+
+When the canvas is empty, Excalidraw can show a welcome _splash_ screen with a logo, a few quick action items, and hints explaining what some of the UI buttons do. Once the user picks a tool, or has created an element on the canvas, the welcome screen will disappear.
+
+You can enable this behavior by rendering a `WelcomeScreen` component like this:
+
+```jsx live
+function App() {
+ return (
+
+
+
+
+
+ );
+}
+```
+
+You can also customize the welcome screen by passing children to the `WelcomeScreen` component. See below.
+
+##
+
+This is the main component. If you render it without any children, we will render the default welcome screen.
+
+You can customize which welcome screen subcomponents are rendered by passing them as children.
+
+The welcome screen consists of two main groups of subcomponents:
+
+1. [WelcomeScreen.Center](#welcomescreencenterlogo).
+2. [WeelcomeScreen.Hints](#welcomescreenhints).
+
+
+
+### Center
+
+`` subcomponent is the center piece of the welcome screen, containing the `logo`, `heading`, and `menu`. All three subcomponents are optional, and you can render whatever you wish into the center component.
+
+```jsx live
+function App() {
+ return (
+
+ );
+}
+```
+
+#### Logo
+
+Use the `` to render a logo. By default it renders the Excalidraw logo and name. Supply `children` to customize.
+
+#### Heading
+
+Use the `` to render a heading below the logo. Supply `children` to change the default message.
+
+#### Menu
+
+`` is a wrapper component for the menu items. You can build your menu using the `` and `` components, render your own, or render one of the default menu items.
+
+The default menu items are:
+
+- `` - opens the help dialog.
+
+- `` - open the load file dialog.
+
+- `` - intended to open the live collaboration dialog. Works similarly to [``](/docs/@excalidraw/excalidraw/api/children-components/live-collaboration-trigger) and you must supply `onSelect()` handler to integrate with your collaboration implementation.
+
+#### MenuItem
+
+The `` component can be used to render a menu item.
+
+| Prop | Type | Required | Default | Description |
+| --- | --- | --- | --- | --- |
+| `onSelect` | `function` | Yes | | The handler is triggered when the item is selected. |
+| `children` | `React.ReactNode` | Yes | | The content of the menu item |
+| `icon` | `JSX.Element` | No | | The icon used in the menu item |
+| `shortcut` | `string` | No | | The keyboard shortcut (label-only, does not affect behavior) |
+
+**WelcomeScreen.Center.MenuItemLink**
+
+To render an external link in a menu item, you can use this component.
+
+| Prop | Type | Required | Default | Description |
+| --- | --- | --- | --- | --- |
+| `href` | `string` | Yes | | The `href` attribute to be added to the `anchor` element. |
+| `children` | `React.ReactNode` | Yes | | The content of the menu item |
+| `icon` | `JSX.Element` | No | | The icon used in the menu item |
+| `shortcut` | `string` | No | | The keyboard shortcut (label-only, does not affect behavior) |
+
+### Hints
+
+These `` subcomponents render the UI hints. Text of each hint can be customized by supplying `children`.
+
+```jsx live
+function App() {
+ return (
+
+
+
+
+
ToolBar Hints
+
+
+
+
+
+
+ );
+}
+```
+
+#### MenuHint
+
+`` hint subcomponent for the main menu. Supply `children` to customize the hint text.
+
+#### ToolbarHint
+
+`` hint subcomponent for the toolbar. Supply `children` to customize the hint text.
+
+#### Help
+
+`` hint subcomponent for the help dialog. Supply `children` to customize the hint text.
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/constants.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/constants.mdx
new file mode 100644
index 000000000..a6c95ab2a
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/constants.mdx
@@ -0,0 +1,46 @@
+# Constants
+
+### FONT_FAMILY
+
+**How to use**
+
+```js
+import { FONT_FAMILY } from "@excalidraw/excalidraw";
+```
+
+`FONT_FAMILY` contains all the font families used in `Excalidraw` as explained below
+
+| Font Family | Description |
+| ----------- | ---------------------- |
+| `Virgil` | The `handwritten` font |
+| `Helvetica` | The `Normal` Font |
+| `Cascadia` | The `Code` Font |
+
+Defaults to `FONT_FAMILY.Virgil` unless passed in `initialData.appState.currentItemFontFamily`.
+
+### THEME
+
+**How to use**
+
+```js
+import { THEME } from "@excalidraw/excalidraw";
+```
+
+`THEME` contains all the themes supported by `Excalidraw` as explained below
+
+| Theme | Description |
+| ------- | ----------------- |
+| `LIGHT` | The `light` theme |
+| `DARK` | The `Dark` theme |
+
+Defaults to `THEME.LIGHT` unless passed in `initialData.appState.theme`
+
+### MIME_TYPES
+
+[`MIME_TYPES`](https://github.com/excalidraw/excalidraw/blob/master/src/constants.ts#L101) contains all the mime types supported by `Excalidraw`.
+
+**How to use **
+
+```js
+import { MIME_TYPES } from "@excalidraw/excalidraw";
+```
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/props/initialdata.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/props/initialdata.mdx
new file mode 100644
index 000000000..7d79128f0
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/props/initialdata.mdx
@@ -0,0 +1,55 @@
+# initialData
+
+
+
+This helps to load Excalidraw with `initialData`. It must be an object or a [promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise) which resolves to an object containing the below optional fields.
+
+| Name | Type | Description |
+| --- | --- | --- |
+| `elements` | [ExcalidrawElement[]](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L114) | The `elements` with which `Excalidraw` should be mounted. |
+| `appState` | [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L95) | The `AppState` with which `Excalidraw` should be mounted. |
+| `scrollToContent` | `boolean` | This attribute indicates whether to `scroll` to the nearest element to center once `Excalidraw` is mounted. By default, it will not scroll the nearest element to the center. Make sure you pass `initialData.appState.scrollX` and `initialData.appState.scrollY` when `scrollToContent` is false so that scroll positions are retained |
+| `libraryItems` | [LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L247) | Promise<[LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L200)> | This library items with which `Excalidraw` should be mounted. |
+| `files` | [BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L82) | The `files` added to the scene. |
+
+You might want to use this when you want to load excalidraw with some initial elements and app state.
+
+```jsx live
+function App() {
+ return (
+
+
+
+ );
+}
+```
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/props/props.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/props/props.mdx
new file mode 100644
index 000000000..a871874c5
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/props/props.mdx
@@ -0,0 +1,230 @@
+# Props
+
+All `props` are *optional*.
+
+| Name | Type | Default | Description |
+| --- | --- | --- | --- |
+| [`initialData`](/docs/@excalidraw/excalidraw/api/props/initialdata) | `object` | `null` | Promise | `null` | The initial data with which app loads. |
+| [`ref`](/docs/@excalidraw/excalidraw/api/props/ref) | `object` | _ | `Ref` to be passed to Excalidraw |
+| [`isCollaborating`](#iscollaborating) | `boolean` | _ | This indicates if the app is in `collaboration` mode |
+| [`onChange`](#onchange) | `function` | _ | This callback is triggered whenever the component updates due to any change. This callback will receive the excalidraw `elements` and the current `app state`. |
+| [`onPointerUpdate`](#onpointerupdate) | `function` | _ | Callback triggered when mouse pointer is updated. |
+| [`onPointerDown`](#onpointerdown) | `function` | _ | This prop if passed gets triggered on pointer down evenets |
+| [`onScrollChange`](#onscrollchange) | `function` | _ | This prop if passed gets triggered when scrolling the canvas. |
+| [`onPaste`](#onpaste) | `function` | _ | Callback to be triggered if passed when the something is pasted in to the scene |
+| [`onLibraryChange`](#onlibrarychange) | `function` | _ | The callback if supplied is triggered when the library is updated and receives the library items. |
+| [`onLinkOpen`](#onlinkopen) | `function` | _ | The callback if supplied is triggered when any link is opened. |
+| [`langCode`](#langcode) | `string` | `en` | Language code string to be used in Excalidraw |
+| [`renderTopRightUI`](/docs/@excalidraw/excalidraw/api/props/render-props#rendertoprightui) | `function` | _ | Render function that renders custom UI in top right corner |
+| [`renderCustomStats`](/docs/@excalidraw/excalidraw/api/props/render-props#rendercustomstats) | `function` | _ | Render function that can be used to render custom stats on the stats dialog. |
+| [`renderSidebar`](/docs/@excalidraw/excalidraw/api/props/render-props#rendersidebar) | `function` | _ | Render function that renders custom sidebar. |
+| [`viewModeEnabled`](#viewmodeenabled) | `boolean` | _ | This indicates if the app is in `view` mode. |
+| [`zenModeEnabled`](#zenmodeenabled) | `boolean` | _ | This indicates if the `zen` mode is enabled |
+| [`gridModeEnabled`](#gridmodeenabled) | `boolean` | _ | This indicates if the `grid` mode is enabled |
+| [`libraryReturnUrl`](#libraryreturnurl) | `string` | _ | What URL should [libraries.excalidraw.com](https://libraries.excalidraw.com) be installed to |
+| [`theme`](#theme) | `"light"` | `"dark"` | `"light"` | The theme of the Excalidraw component |
+| [`name`](#name) | `string` | | Name of the drawing |
+| [`UIOptions`](/docs/@excalidraw/excalidraw/api/props/ui-options) | `object` | [DEFAULT UI OPTIONS](https://github.com/excalidraw/excalidraw/blob/master/src/constants.ts#L151) | To customise UI options. Currently we support customising [`canvas actions`](#canvasactions) |
+| [`detectScroll`](#detectscroll) | `boolean` | `true` | Indicates whether to update the offsets when nearest ancestor is scrolled. |
+| [`handleKeyboardGlobally`](#handlekeyboardglobally) | `boolean` | `false` | Indicates whether to bind the keyboard events to document. |
+| [`autoFocus`](#autofocus) | `boolean` | `false` | indicates whether to focus the Excalidraw component on page load |
+| [`generateIdForFile`](#generateidforfile) | `function` | _ | Allows you to override `id` generation for files added on canvas |
+
+### Storing custom data on Excalidraw elements
+
+Beyond attributes that Excalidraw elements already support, you can store `custom` data on each `element` in a `customData` object. The type of the attribute is [`Record`](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L66) and is optional.
+
+You can use this to add any extra information you need to keep track of.
+
+You can add `customData` to elements when passing them as [`initialData`](/docs/@excalidraw/excalidraw/api/props/initialdata), or using [`updateScene`](/docs/@excalidraw/excalidraw/api/props/ref#updatescene) / [`updateLibrary`](/docs/@excalidraw/excalidraw/api/props/ref#updatelibrary) afterwards.
+
+```js showLineNumbers
+{
+ type: "rectangle",
+ id: "oDVXy8D6rom3H1-LLH2-f",
+ customData: {customId: '162'},
+}
+```
+
+### isCollaborating
+
+This prop indicates if the app is in `collaboration` mode.
+
+### onChange
+
+Every time component updates, this callback if passed will get triggered and has the below signature.
+
+```js
+(excalidrawElements, appState, files) => void;
+```
+
+1. `excalidrawElements`: Array of [excalidrawElements](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L114) in the scene.
+
+2. `appState`: [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L95) of the scene.
+
+3. `files`: The [BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64) which are added to the scene.
+
+Here you can try saving the data to your backend or local storage for example.
+
+### onPointerUpdate
+
+This callback is triggered when mouse pointer is updated.
+
+```js
+({ x, y }, button, pointersMap}) => void;
+```
+
+1.`{x, y}`: Pointer coordinates
+
+2.`button`: The position of the button. This will be one of `["down", "up"]`
+
+3.`pointersMap`: [`pointers`](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L131) map of the scene
+
+```js
+(exportedElements, appState, canvas) => void
+```
+
+1. `exportedElements`: An array of [non deleted elements](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L87) which needs to be exported.
+2. `appState`: [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L95) of the scene.
+3. `canvas`: The `HTMLCanvasElement` of the scene.
+
+### onPointerDown
+
+This prop if passed will be triggered on pointer down events and has the below signature.
+
+
+
+### onScrollChange
+
+This prop if passed will be triggered when canvas is scrolled and has the below signature.
+
+```ts
+(scrollX: number, scrollY: number) => void
+```
+
+### onPaste
+
+This callback is triggered if passed when something is pasted into the scene. You can use this callback in case you want to do something additional when the paste event occurs.
+
+
+
+This callback must return a `boolean` value or a [promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise) which resolves to a boolean value.
+
+In case you want to prevent the excalidraw paste action you must return `false`, it will stop the native excalidraw clipboard management flow (nothing will be pasted into the scene).
+
+### onLibraryChange
+
+This callback if supplied will get triggered when the library is updated and has the below signature.
+
+
+
+It is invoked with empty items when user clears the library. You can use this callback when you want to do something additional when library is updated for example persisting it to local storage.
+
+### onLinkOpen
+
+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()`.
+
+
+
+Example:
+
+```js showLineNumbers
+const history = useHistory();
+
+// open internal links using the app's router, but opens external links in
+// a new tab/window
+const onLinkOpen: ExcalidrawProps["onLinkOpen"] = useCallback(
+ (element, event) => {
+ const link = element.link;
+ const { nativeEvent } = event.detail;
+ const isNewTab = nativeEvent.ctrlKey || nativeEvent.metaKey;
+ const isNewWindow = nativeEvent.shiftKey;
+ const isInternalLink =
+ link.startsWith("/") || link.includes(window.location.origin);
+ if (isInternalLink && !isNewTab && !isNewWindow) {
+ history.push(link.replace(window.location.origin, ""));
+ // signal that we're handling the redirect ourselves
+ event.preventDefault();
+ }
+ },
+ [history],
+);
+```
+
+### langCode
+
+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
+import { defaultLang, languages } from "@excalidraw/excalidraw";
+```
+
+| name | type |
+| --- | --- |
+| `defaultLang` | `string` |
+| `languages` | [`Language[]`](https://github.com/excalidraw/excalidraw/blob/master/src/i18n.ts#L15) |
+
+### viewModeEnabled
+
+This prop indicates whether the app is in `view mode`. When supplied, the value takes precedence over *intialData.appState.viewModeEnabled*, the `view mode` will be fully controlled by the host app, and users won't be able to toggle it from within the app.
+
+### zenModeEnabled
+
+This prop indicates whether the app is in `zen mode`. When supplied, the value takes precedence over *intialData.appState.zenModeEnabled*, the `zen mode` will be fully controlled by the host app, and users won't be able to toggle it from within the app.
+
+### gridModeEnabled
+
+This prop indicates whether the shows the grid. When supplied, the value takes precedence over *intialData.appState.gridModeEnabled*, the grid will be fully controlled by the host app, and users won't be able to toggle it from within the app.
+
+### libraryReturnUrl
+
+If supplied, this URL will be used when user tries to install a library from [libraries.excalidraw.com](https://libraries.excalidraw.com).
+Defaults to *window.location.origin + window.location.pathname*. To install the libraries in the same tab from which it was opened, you need to set `window.name` (to any alphanumeric string) — if it's not set it will open in a new tab.
+
+### theme
+
+This prop controls Excalidraw's theme. When supplied, the value takes precedence over *intialData.appState.theme*, the theme will be fully controlled by the host app, and users won't be able to toggle it from within the app unless *UIOptions.canvasActions.toggleTheme* is set to `true`, in which case the `theme` prop will control Excalidraw's default theme with ability to allow theme switching (you must take care of updating the `theme` prop when you detect a change to `appState.theme` from the [onChange](#onchange) callback).
+
+You can use [`THEME`](/docs/@excalidraw/excalidraw/api/utils#theme) to specify the theme.
+
+### name
+
+This prop sets the `name` of the drawing which will be used when exporting the drawing. When supplied, the value takes precedence over *intialData.appState.name*, the `name` will be fully controlled by host app and the users won't be able to edit from within Excalidraw.
+
+
+### detectScroll
+
+Indicates whether Excalidraw should listen for `scroll` event on the nearest scrollable container in the DOM tree and recompute the coordinates (e.g. to correctly handle the cursor) when the component's position changes. You can disable this when you either know this doesn't affect your app or you want to take care of it yourself (calling the [`refresh()`](#ref) method).
+
+### handleKeyboardGlobally
+
+Indicates whether to bind keyboard events to `document`. Disabled by default, meaning the keyboard events are bound to the Excalidraw component. This allows for multiple Excalidraw components to live on the same page, and ensures that Excalidraw keyboard handling doesn't collide with your app's (or the browser) when the component isn't focused.
+
+Enable this if you want Excalidraw to handle keyboard even if the component isn't focused (e.g. a user is interacting with the navbar, sidebar, or similar).
+
+
+### autoFocus
+
+This prop indicates whether to `focus` the Excalidraw component on page load. Defaults to false.
+
+### generateIdForFile
+
+Allows you to override `id` generation for files added on canvas (images). By default, an SHA-1 digest of the file is used.
+
+```tsx
+(file: File) => string | Promise
+```
+
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/props/ref.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/props/ref.mdx
new file mode 100644
index 000000000..08e807907
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/props/ref.mdx
@@ -0,0 +1,421 @@
+# ref
+
+
+
+You can pass a `ref` when you want to access some excalidraw APIs. We expose the below APIs:
+
+| API | Signature | Usage |
+| --- | --- | --- |
+| ready | `boolean` | This is set to true once Excalidraw is rendered |
+| [readyPromise](#readypromise) | `function` | This promise will be resolved with the api once excalidraw has rendered. This will be helpful when you want do some action on the host app once this promise resolves. For this to work you will have to pass ref as shown [here](#readypromise) |
+| [updateScene](#updatescene) | `function` | updates the scene with the sceneData |
+| [updateLibrary](#updatelibrary) | `function` | updates the scene with the sceneData |
+| [addFiles](#addfiles) | `function` | add files data to the appState |
+| [resetScene](#resetscene) | `function` | Resets the scene. If `resetLoadingState` is passed as true then it will also force set the loading state to false. |
+| [getSceneElementsIncludingDeleted](#getsceneelementsincludingdeleted) | `function` | Returns all the elements including the deleted in the scene |
+| [getSceneElements](#getsceneelements) | `function` | Returns all the elements excluding the deleted in the scene |
+| [getAppState](#getappstate) | `function` | Returns current appState |
+| [history](#history) | `object` | This is the history API. `history.clear()` will clear the history |
+| [scrollToContent](#scrolltocontent) | `function` | Scroll the nearest element out of the elements supplied to the center. Defaults to the elements on the scene. |
+| [refresh](#refresh) | `function` | Updates the offsets for the Excalidraw component so that the coordinates are computed correctly (for example the cursor position). |
+| [setToast](#settoast) | `function` | This API can be used to show the toast with custom message. |
+| [id](#id) | `string` | Unique ID for the excalidraw component. |
+| [getFiles](#getfiles) | `function` | This API can be used to get the files present in the scene. |
+| [setActiveTool](#setactivetool) | `function` | This API can be used to set the active tool |
+| [setCursor](#setcursor) | `function` | This API can be used to set customise the mouse cursor on the canvas |
+| [resetCursor](#resetcursor) | `function` | This API can be used to reset to default mouse cursor on the canvas |
+| [toggleMenu](#togglemenu) | `function` | Toggles specific menus on/off |
+
+## readyPromise
+
+
+
+Since plain object is passed as a `ref`, the `readyPromise` is resolved as soon as the component is mounted. Most of the time you will not need this unless you have a specific use case where you can't pass the `ref` in the react way and want to do some action on the host when this promise resolves.
+
+```jsx showLineNumbers
+const resolvablePromise = () => {
+ let resolve;
+ let reject;
+ const promise = new Promise((_resolve, _reject) => {
+ resolve = _resolve;
+ reject = _reject;
+ });
+ promise.resolve = resolve;
+ promise.reject = reject;
+ return promise;
+};
+
+const App = () => {
+ const excalidrawRef = useMemo(
+ () => ({
+ current: {
+ readyPromise: resolvablePromise(),
+ },
+ }),
+ [],
+ );
+
+ useEffect(() => {
+ excalidrawRef.current.readyPromise.then((api) => {
+ console.log("loaded", api);
+ });
+ }, [excalidrawRef]);
+ return (
+
+
+Adds supplied files data to the `appState.files` cache on top of existing files present in the cache.
+
+## resetScene
+
+```tsx
+(opts?: { resetLoadingState: boolean }) => void
+```
+
+Resets the scene. If `resetLoadingState` is passed as true then it will also force set the loading state to false.
+
+## getSceneElementsIncludingDeleted
+
+
+
+Returns current appState.
+
+## history
+
+```tsx
+{
+ clear: () => void
+}
+```
+
+This is the history API. history.clear() will clear the history.
+
+## scrollToContent
+
+
+
+Scroll the nearest element out of the elements supplied to the center of the viewport. Defaults to the elements on the scene.
+
+| Attribute | type | default | Description |
+| --- | --- | --- | --- |
+| target | ExcalidrawElement | ExcalidrawElement[] | All scene elements | The element(s) to scroll to. |
+| opts.fitToContent | boolean | false | Whether to fit the elements to viewport by automatically changing zoom as needed. |
+| opts.animate | boolean | false | Whether to animate between starting and ending position. Note that for larger scenes the animation may not be smooth due to performance issues. |
+| opts.duration | number | 500 | Duration of the animation if `opts.animate` is `true`. |
+
+## refresh
+
+```tsx
+() => void
+```
+
+Updates the `offsets` for the `Excalidraw` component so that the coordinates are computed correctly (for example the cursor position).
+
+You don't have to call this when the position is changed on page scroll or when the excalidraw container resizes (we handle that ourselves).
+
+For any other cases if the position of excalidraw is updated (example due to scroll on parent container and not page scroll) you should call this API.
+
+## setToast
+
+This API can be used to show the toast with custom message.
+
+```tsx
+({ message: string, closable?:boolean,duration?:number
+ } | null) => void
+```
+
+| Attribute | type | Description |
+| --- | --- | --- |
+| message | string | The message to be shown on the toast. |
+| closable | boolean | Indicates whether to show the closable button on toast to dismiss the toast. |
+| duration | number | Determines the duration after which the toast should auto dismiss. To prevent autodimiss you can pass `Infinity`. |
+
+To dismiss an existing toast you can simple pass `null`
+
+```js
+setToast(null);
+```
+
+## id
+
+The unique id of the excalidraw component. This can be used to identify the excalidraw component, for example importing the library items to the excalidraw component from where it was initiated when you have multiple excalidraw components rendered on the same page as shown in [multiple excalidraw demo](https://codesandbox.io/s/multiple-excalidraw-k1xx5).
+
+## getFiles
+
+
+
+This API can be used to get the files present in the scene. It may contain files that aren't referenced by any element, so if you're persisting the files to a storage, you should compare them against stored elements.
+
+## setActiveTool
+
+This API has the below signature. It sets the `tool` passed in param as the active tool.
+
+
+
+## setCursor
+
+This API can be used to customise the mouse cursor on the canvas and has the below signature. It sets the mouse cursor to the cursor passed in param.
+
+```tsx
+(cursor: string) => void
+```
+
+## toggleMenu
+
+```tsx
+(type: "library" | "customSidebar", force?: boolean) => boolean;
+```
+
+This API can be used to toggle a specific menu (currently only the sidebars), and returns whether the menu was toggled on or off. If the `force` flag passed, it will force the menu to be toggled either on/off based on the `boolean` passed.
+
+This API is especially useful when you render a custom sidebar using [`renderSidebar`](#rendersidebar) prop, and you want to toggle it from your app based on a user action.
+
+## resetCursor
+
+```tsx
+() => void
+```
+
+This API can be used to reset to default mouse cursor.
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/props/render-props.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/props/render-props.mdx
new file mode 100644
index 000000000..ca329e3e6
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/props/render-props.mdx
@@ -0,0 +1,126 @@
+# Render Props
+
+## renderTopRightUI
+
+
+
+A function returning `JSX` to render `custom` UI in the top right corner of the app.
+
+```jsx live
+function App() {
+ return (
+
+ {
+ return (
+
+ );
+ }}
+ />
+
+ );
+}
+```
+
+## renderCustomStats
+
+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 as do in [excalidraw.com](https://excalidraw.com).
+
+```jsx live
+function App() {
+ return (
+
+ (
+
+ {" "}
+ Dummy stats will be shown here{" "}
+
+ )}
+ />
+
+ );
+}
+```
+
+## renderSidebar
+
+```tsx
+() => JSX | null;
+```
+
+You can render `custom sidebar` using this prop. This sidebar is the same that the library menu sidebar is using, and can be used for any purposes your app needs.
+
+You need to import the `Sidebar` component from `excalidraw` package and pass your content as its `children`. The function `renderSidebar` should return the `Sidebar` instance.
+
+### Sidebar
+The `` component takes these props (all are optional except `children`):
+
+| Prop | Type | Description |
+| --- | --- | --- |
+| `children` | `React.ReactNode` | Content you want to render inside the `sidebar`. |
+| `onClose` | `function` | Invoked when the component is closed (by user, or the editor). No need to act on this event, as the editor manages the sidebar open state on its own. |
+| `onDock` | `function` | Invoked when the user toggles the `dock` button. The callback recieves a `boolean` parameter `isDocked` which indicates whether the sidebar is `docked` |
+| `docked` | `boolean` | Indicates whether the sidebar is`docked`. By default, the sidebar is `undocked`. If passed, the docking becomes controlled, and you are responsible for updating the `docked` state by listening on `onDock` callback. To decide the breakpoint for docking you can use [UIOptions.dockedSidebarBreakpoint](/docs/@excalidraw/excalidraw/api/props/ui-options#dockedsidebarbreakpoint) for more info on docking. |
+| `dockable` | `boolean` | Indicates whether to show the `dock` button so that user can `dock` the sidebar. If `false`, you can still dock programmatically by passing `docked` as `true`. |
+
+The sidebar will always include a header with `close / dock` buttons (when applicable).
+You can also add custom content to the header, by rendering `` as a child of the `` component. Note that the custom header will still include the default buttons.
+
+
+### Sidebar.Header
+
+| name | type | description |
+| --- | --- | --- |
+| children | `React.ReactNode` | Content you want to render inside the sidebar header as a sibling of `close` / `dock` buttons. |
+
+To control the visibility of the sidebar you can use [`toggleMenu("customSidebar")`](/docs/@excalidraw/excalidraw/api/props/ref#togglemenu) api available via `ref`.
+
+```tsx live
+function App() {
+ const [excalidrawAPI, setExcalidrawAPI] = useState(null);
+
+ return (
+
+ );
+}
+```
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/props/ui-options.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/props/ui-options.mdx
new file mode 100644
index 000000000..d7551e366
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/props/ui-options.mdx
@@ -0,0 +1,72 @@
+# UIOptions
+
+This prop can be used to customise UI of Excalidraw. Currently we support customising [`canvasActions`](#canvasactions), [`dockedSidebarBreakpoint`](#dockedsidebarbreakpoint) and [`welcomeScreen`](#welcmescreen).
+
+
+
+## canvasActions
+
+This `prop` controls the visibility of the canvas actions inside the `menu`.
+
+| Prop | Type | Default | Description |
+| --- | --- | --- | --- |
+| `changeViewBackgroundColor` | `boolean` | `true` | Indicates whether to show `Background color picker`. |
+| `clearCanvas` | `boolean` | `true` | Indicates whether to show `Clear canvas` button. |
+| `export` | `false` | [`exportOpts`](#exportopts) | `object` | This prop allows to customize the UI inside the export dialog. By default it shows the `save file to disk`. For more details visit [`exportOpts`](#exportopts). |
+| `loadScene` | `boolean` | `true` | Indicates whether to show `Load` button. |
+| `saveToActiveFile` | `boolean` | `true` | Indicates whether to show `Save` button to save to current file. |
+| `toggleTheme` | `boolean` | `null` | `null` | Indicates whether to show `Theme toggle`. When defined as `boolean`, takes precedence over [`props.theme`](/docs/@excalidraw/excalidraw/api/props#theme) to show `Theme toggle`. |
+| `saveAsImage` | `boolean` | `true` | Indicates whether to show `Save as image` button. |
+
+```tsx live
+function App() {
+ const UIOptions = {
+ canvasActions: {
+ changeViewBackgroundColor: false,
+ clearCanvas: false,
+ loadScene: false,
+ },
+ };
+ return (
+
+
+
+ );
+}
+```
+
+### exportOpts
+
+The below attributes can be set in `UIOptions.canvasActions.export` to customize the export dialog.
+If `UIOptions.canvasActions.export` is `false` the export button will not be rendered.
+
+| Prop | Type | Default | Description |
+| --- | --- | --- | --- |
+| `saveFileToDisk` | `boolean` | `true` | Indicates whether `save file to disk` button should be shown |
+| `onExportToBackend` | `object` | \_ | This callback is triggered when the shareable-link button is clicked in the export dialog. The link button will only be shown if this callback is passed. |
+| `renderCustomUI` | `object` | \_ | This callback should be supplied if you want to render custom UI in the export dialog. |
+
+## dockedSidebarBreakpoint
+
+This prop indicates at what point should we break to a docked, permanent sidebar. If not passed it defaults to [`MQ_RIGHT_SIDEBAR_MAX_WIDTH_PORTRAIT`](https://github.com/excalidraw/excalidraw/blob/master/src/constants.ts#L161).
+If the _width_ of the _excalidraw_ container exceeds _dockedSidebarBreakpoint_, the sidebar will be `dockable` and the button to `dock` the sidebar will be shown
+If user choses to `dock` the sidebar, it will push the right part of the UI towards the left, making space for the sidebar as shown below.
+
+
+
+```tsx live
+function App() {
+ return (
+
+
+
+ );
+}
+```
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/utils/export.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/utils/export.mdx
new file mode 100644
index 000000000..f5469f01d
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/utils/export.mdx
@@ -0,0 +1,196 @@
+---
+title: Export Utilities
+id: "export"
+---
+
+:::info
+
+We're working on much improved export utilities. Stay tuned!
+
+:::
+
+### exportToCanvas
+
+**_Signature_**
+
+
+
+| Name | Type | Default | Description |
+| --- | --- | --- | --- |
+| `elements` | [Excalidraw Element []](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L114) | | The elements to be exported to canvas. |
+| `appState` | [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/packages/utils.ts#L23) | [Default App State](https://github.com/excalidraw/excalidraw/blob/master/src/appState.ts#L17) | The app state of the scene. |
+| [`getDimensions`](#getdimensions) | `function` | _ | A function which returns the `width`, `height`, and optionally `scale` (defaults to `1`), with which canvas is to be exported. |
+| `maxWidthOrHeight` | `number` | _ | The maximum `width` or `height` of the exported image. If provided, `getDimensions` is ignored. |
+| `files` | [BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L59) | _ | The files added to the scene. |
+| `exportPadding` | `number` | `10` | The `padding` to be added on canvas. |
+
+
+#### getDimensions
+
+```tsx
+(width: number, height: number) => {
+ width: number,
+ height: number,
+ scale?: number
+}
+```
+A function which returns the `width`, `height`, and optionally `scale` (defaults to `1`), with which canvas is to be exported.
+
+**How to use**
+
+```js
+import { exportToCanvas } from "@excalidraw/excalidraw";
+```
+
+This function returns the canvas with the exported elements, appState and dimensions.
+
+```jsx live
+function App() {
+ const [canvasUrl, setCanvasUrl] = useState("");
+ const [excalidrawAPI, setExcalidrawAPI] = useState(null);
+
+ return (
+ <>
+
+
+
+| Name | Type | Default | Description |
+| --- | --- | --- | --- |
+| `opts` | `object` | _ | This param is passed to `exportToCanvas`. You can refer to [`exportToCanvas`](#exporttocanvas) |
+| `mimeType` | `string` | `image/png` | Indicates the image format. |
+| `quality` | `number` | `0.92` | A value between `0` and `1` indicating the [image quality](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#parameters). Applies only to `image/jpeg`/`image/webp` MIME types. |
+| `exportPadding` | `number` | `10` | The padding to be added on canvas. |
+
+**How to use**
+
+```js
+import { exportToBlob } from "@excalidraw/excalidraw";
+```
+
+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).
+
+### exportToSvg
+
+**_Signature_**
+
+
+
+| Name | Type | Default | Description |
+| --- | --- | --- | --- |
+| elements | [Excalidraw Element []](https://github.com/excalidraw/excalidraw/blob/master/src/element/types.ts#L114) | | The elements to exported as `svg `|
+| appState | [AppState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L95) | [defaultAppState](https://github.com/excalidraw/excalidraw/blob/master/src/appState.ts#L11) | The `appState` of the scene |
+| exportPadding | number | 10 | The `padding` to be added on canvas |
+| files | [BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64) | undefined | The `files` added to the scene. |
+
+This function returns a promise which resolves to `svg` of the exported drawing.
+
+### exportToClipboard
+
+**_Signature_**
+
+
+
+| Name | Type | Default | Description |
+| --- | --- | --- | --- |
+| `opts` | | | This param is same as the params passed to `exportToCanvas`. You can refer to [`exportToCanvas`](#exporttocanvas). |
+| `mimeType` | `string` | `image/png` | Indicates the image format, this will be used when exporting as `png`. |
+| `quality` | `number` | `0.92` | A value between `0` and `1` indicating the [image quality](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#parameters). Applies only to `image/jpeg` / `image/webp` MIME types. This will be used when exporting as `png`. |
+| `type` | 'png' | 'svg' | 'json' | _ | This determines the format to which the scene data should be `exported`. |
+
+**How to use**
+
+```js
+import { exportToClipboard } from "@excalidraw/excalidraw";
+```
+
+Copies the scene data in the specified format (determined by `type`) to clipboard.
+
+### Additional attributes of appState for export\* APIs
+
+| Name | Type | Default | Description |
+| --- | --- | --- | --- |
+| `exportBackground` | `boolean` | `true` | Indicates whether `background` should be exported |
+| `viewBackgroundColor` | `string` | `#fff` | The default background color |
+| `exportWithDarkMode` | `boolean` | `false` | Indicates whether to export with `dark` mode |
+| `exportEmbedScene` | `boolean` | `false` | Indicates whether scene data should be embedded in `svg/png`. This will increase the image size. |
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/utils/restore.mdx b/dev-docs/docs/@excalidraw/excalidraw/api/utils/restore.mdx
new file mode 100644
index 000000000..665a1ef9f
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/utils/restore.mdx
@@ -0,0 +1,108 @@
+---
+title: Restore Utilities
+id: "restore"
+---
+
+### restoreAppState
+
+**_Signature_**
+
+
+
+**_How to use_**
+
+```js
+import { restoreAppState } from "@excalidraw/excalidraw";
+```
+
+This function will make sure all the `keys` have appropriate `values` in [appState](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L95) and if any key is missing, it will be set to its `default` value.
+
+When `localAppState` is supplied, it's used in place of values that are missing (`undefined`) in `appState` instead of the defaults.
+Use this as a way to not override user's defaults if you persist them.
+You can pass `null` / `undefined` if not applicable.
+
+### restoreElements
+
+**_Signature_**
+
+
+
+| Prop | Type | Description |
+| ---- | ---- | ---- |
+| `elements` | ImportedDataState["elements"] | The `elements` to be restored |
+| [`localElements`](#localelements) | ExcalidrawElement[] | null | undefined | When `localElements` are supplied, they are used to ensure that existing restored elements reuse `version` (and increment it), and regenerate `versionNonce`. |
+| [`opts`](#opts) | `Object` | The extra optional parameter to configure restored elements
+
+#### localElements
+
+When `localElements` are supplied, they are used to ensure that existing restored elements reuse `version` (and increment it), and regenerate `versionNonce`.
+Use this when you `import` elements which may already be present in the scene to ensure that you do not disregard the newly imported elements if you're using element version to detect the update
+
+#### opts
+The extra optional parameter to configure restored elements. It has the following attributes
+
+| Prop | Type | Description|
+| --- | --- | ------|
+| `refreshDimensions` | `boolean` | Indicates whether we should also `recalculate` text element dimensions. Since this is a potentially costly operation, you may want to disable it if you restore elements in tight loops, such as during collaboration. |
+| `repairBindings` |`boolean` | Indicates whether the `bindings` for the elements should be repaired. This is to make sure there are no containers with non existent bound text element id and no bound text elements with non existent container id. |
+
+**_How to use_**
+
+```js
+import { restoreElements } from "@excalidraw/excalidraw";
+```
+
+This function will make sure all properties of element is correctly set and if any attribute is missing, it will be set to its default value.
+
+Parameter `refreshDimensions` indicates whether we should also `recalculate` text element dimensions. Defaults to `false`. Since this is a potentially costly operation, you may want to disable it if you restore elements in tight loops, such as during collaboration.
+
+### restore
+
+**_Signature_**
+
+
+
+See [`restoreAppState()`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#restoreAppState) about `localAppState`, and [`restoreElements()`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#restoreElements) about `localElements`.
+
+**_How to use_**
+
+```js
+import { restore } from "@excalidraw/excalidraw";
+```
+
+This function makes sure elements and state is set to appropriate values and set to default value if not present. It is a combination of [restoreElements](#restoreelements) and [restoreAppState](#restoreappstate).
+
+### restoreLibraryItems
+
+**_Signature_**
+
+
+
+**_How to use_**
+
+```js
+import { restoreLibraryItems } from "@excalidraw/excalidraw";
+
+restoreLibraryItems(libraryItems, "unpublished");
+```
+
+This function normalizes library items elements, adding missing values when needed.
diff --git a/dev-docs/docs/@excalidraw/excalidraw/api/utils/utils-intro.md b/dev-docs/docs/@excalidraw/excalidraw/api/utils/utils-intro.md
new file mode 100644
index 000000000..4d2745c09
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/api/utils/utils-intro.md
@@ -0,0 +1,385 @@
+---
+slug: /@excalidraw/excalidraw/api/utils
+---
+
+# Utils
+
+These are pure Javascript functions exported from the @excalidraw/excalidraw [`@excalidraw/excalidraw`](https://npmjs.com/@excalidraw/excalidraw). If you want to export your drawings in different formats eg `png`, `svg` and more you can check out [Export Utilities](/docs/@excalidraw/excalidraw/API/utils/export). If you want to restore your drawings you can check out [Restore Utilities](/docs/@excalidraw/excalidraw/API/utils/restore).
+
+### serializeAsJSON
+
+Takes the scene elements and state and returns a JSON string. `Deleted` elements as well as most properties from `AppState` are removed from the resulting JSON. (see [`serializeAsJSON()`](https://github.com/excalidraw/excalidraw/blob/master/src/data/json.ts#L42) source for details).
+
+If you want to overwrite the `source` field in the `JSON` string, you can set `window.EXCALIDRAW_EXPORT_SOURCE` to the desired value.
+
+**_Signature_**
+
+
+
+**How to use**
+
+```js
+import { serializeAsJSON } from "@excalidraw/excalidraw";
+```
+
+### serializeLibraryAsJSON
+
+Takes the `library` items and returns a `JSON` string.
+
+If you want to overwrite the source field in the JSON string, you can set `window.EXCALIDRAW_EXPORT_SOURCE` to the desired value.
+
+**_Signature_**
+
+
+
+**How to use**
+
+```js
+import { serializeLibraryAsJSON } from "@excalidraw/excalidraw";
+```
+
+#### isInvisiblySmallElement
+
+Returns `true` if element is invisibly small (e.g. width & height are zero).
+
+**_Signature_**
+
+
+
+**How to use**
+
+```js
+import { isInvisiblySmallElement } from "@excalidraw/excalidraw";
+```
+
+### loadFromBlob
+
+This function loads the scene data from the blob (or file). If you pass `localAppState`, `localAppState` value will be preferred over the `appState` derived from `blob`. Throws if blob doesn't contain valid scene data.
+
+**How to use**
+
+```js
+import { loadFromBlob } from "@excalidraw/excalidraw";
+
+const scene = await loadFromBlob(file, null, null);
+excalidrawAPI.updateScene(scene);
+```
+
+**Signature**
+
+
+
+### loadLibraryFromBlob
+
+This function loads the library from the blob. Additonally takes `defaultStatus` param which sets the default status for library item if not present, defaults to `unpublished`.
+
+**How to use **
+
+```js
+import { loadLibraryFromBlob } from "@excalidraw/excalidraw";
+```
+
+**_Signature_**
+
+
+
+### loadSceneOrLibraryFromBlob
+
+This function loads either scene or library data from the supplied blob. If the blob contains scene data, and you pass `localAppState`, `localAppState` value will be preferred over the `appState` derived from `blob`.
+
+:::caution
+
+Throws if blob doesn't contain valid `scene` data or `library` data.
+
+:::
+
+**How to use**
+
+```js showLineNumbers
+import { loadSceneOrLibraryFromBlob, MIME_TYPES } from "@excalidraw/excalidraw";
+
+const contents = await loadSceneOrLibraryFromBlob(file, null, null);
+if (contents.type === MIME_TYPES.excalidraw) {
+ excalidrawAPI.updateScene(contents.data);
+} else if (contents.type === MIME_TYPES.excalidrawlib) {
+ excalidrawAPI.updateLibrary(contents.data);
+}
+```
+
+**_Signature_**
+
+
+
+### mergeLibraryItems
+
+This function merges two `LibraryItems` arrays, where unique items from `otherItems` are sorted first in the returned array.
+
+```js
+import { mergeLibraryItems } from "@excalidraw/excalidraw";
+```
+
+**_Signature_**
+
+
+
+### parseLibraryTokensFromUrl
+
+Parses library parameters from URL if present (expects the `#addLibrary` hash key), and returns an object with the `libraryUrl` and `idToken`. Returns `null` if `#addLibrary` hash key not found.
+
+**How to use**
+
+```js
+import { parseLibraryTokensFromUrl } from "@excalidraw/excalidraw";
+```
+
+**Signature**
+
+```tsx
+parseLibraryTokensFromUrl(): {
+ libraryUrl: string;
+ idToken: string | null;
+} | null
+```
+
+### useHandleLibrary
+
+A hook that automatically imports library from url if `#addLibrary` hash key exists on initial load, or when it changes during the editing session (e.g. when a user installs a new library), and handles initial library load if `getInitialLibraryItems` getter is supplied.
+
+**How to use**
+
+```js
+import { useHandleLibrary } from "@excalidraw/excalidraw";
+
+export const App = () => {
+ // ...
+ useHandleLibrary({ excalidrawAPI });
+};
+```
+
+**Signature**
+
+
+
+In the future, we will be adding support for handling `library` persistence to `browser storage` (or elsewhere).
+
+### getSceneVersion
+
+This function returns the current `scene` version.
+
+**_Signature_**
+
+
+
+### useDevice
+
+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.
+
+Open the `main menu` in the below example to view the footer.
+
+```jsx live noInline
+const MobileFooter = ({}) => {
+ const device = useDevice();
+ if (device.isMobile) {
+ return (
+
+ );
+ }
+ return null;
+};
+const App = () => (
+
+
+
+ Item1
+ Item 2
+
+
+
+
+);
+
+// Need to render when code is span across multiple components
+// in Live Code blocks editor
+render();
+```
+
+The `device` has the following `attributes`
+
+| Name | Type | Description |
+| --- | --- | --- |
+| `isSmScreen` | `boolean` | Set to `true` when the device small screen is small (Width < `640px` ) |
+| `isMobile` | `boolean` | Set to `true` when the device is `mobile` |
+| `isTouchScreen` | `boolean` | Set to `true` for `touch` devices |
+| `canDeviceFitSidebar` | `boolean` | Implies whether there is enough space to fit the `sidebar` |
+
+### i18n
+
+To help with localization, we export the following.
+
+| name | type |
+| --- | --- |
+| `defaultLang` | `string` |
+| `languages` | [`Language[]`](https://github.com/excalidraw/excalidraw/blob/master/src/i18n.ts#L15) |
+| `useI18n` | [`() => { langCode, t }`](https://github.com/excalidraw/excalidraw/blob/master/src/i18n.ts#L15) |
+
+```js
+import { defaultLang, languages, useI18n } from "@excalidraw/excalidraw";
+```
+
+#### defaultLang
+
+Default language code, `en`.
+
+#### languages
+
+List of supported language codes. You can pass any of these to `Excalidraw`'s [`langCode` prop](/docs/@excalidraw/excalidraw/api/props/#langcode).
+
+#### useI18n
+
+A hook that returns the current language code and translation helper function. You can use this to translate strings in the components you render as children of ``.
+
+```jsx live
+function App() {
+ const { t } = useI18n();
+ return (
+
+
+
+
+
+ );
+}
+```
diff --git a/dev-docs/docs/@excalidraw/excalidraw/customizing-styles.mdx b/dev-docs/docs/@excalidraw/excalidraw/customizing-styles.mdx
new file mode 100644
index 000000000..7a1d423fc
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/customizing-styles.mdx
@@ -0,0 +1,49 @@
+# Customizing Styles
+
+Excalidraw is using CSS variables to style certain components. To override them, you should set your own on the `.excalidraw` and `.excalidraw.theme--dark` (for dark mode variables) selectors.
+
+Make sure the selector has higher specificity, e.g. by prefixing it with your app's selector:
+
+```css
+.your-app .excalidraw {
+ --color-primary: red;
+}
+.your-app .excalidraw.theme--dark {
+ --color-primary: pink;
+}
+```
+
+Most notably, you can customize the primary colors, by overriding these variables:
+
+- `--color-primary`
+- `--color-primary-darker`
+- `--color-primary-darkest`
+- `--color-primary-light`
+- `--color-primary-contrast-offset` — a slightly darker (in light mode), or lighter (in dark mode) `--color-primary` color to fix contrast issues (see [Chubb illusion](https://en.wikipedia.org/wiki/Chubb_illusion)). It will fall back to `--color-primary` if not present.
+
+For a complete list of variables, check [theme.scss](https://github.com/excalidraw/excalidraw/blob/master/src/css/theme.scss), though most of them will not make sense to override.
+
+```css showLineNumbers
+.custom-styles .excalidraw {
+ --color-primary: #fcc6d9;
+ --color-primary-darker: #f783ac;
+ --color-primary-darkest: #e64980;
+ --color-primary-light: #f2a9c4;
+}
+
+.custom-styles .excalidraw.theme--dark {
+ --color-primary: #d494aa;
+ --color-primary-darker: #d64c7e;
+ --color-primary-darkest: #e86e99;
+ --color-primary-light: #dcbec9;
+}
+```
+```tsx live
+function App() {
+ return (
+
+
+
+ );
+}
+```
diff --git a/dev-docs/docs/@excalidraw/excalidraw/development.mdx b/dev-docs/docs/@excalidraw/excalidraw/development.mdx
new file mode 100644
index 000000000..066e0a24e
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/development.mdx
@@ -0,0 +1,59 @@
+---
+pagination_prev: "@excalidraw/excalidraw/installation"
+---
+
+# Development
+
+This page relates to developing the `@excalidraw/excalidraw` package itself.
+
+## Example app
+
+To start the example app using the `@excalidraw/excalidraw` package, follow the below steps:
+
+1. Install the dependencies
+
+ ```bash
+ cd src/packages/excalidraw && yarn
+ ```
+
+2. Start the example app
+
+ ```bash
+ yarn start
+ ```
+
+ [http://localhost:3001](http://localhost:3001) will open in your default browser.
+
+ The example is same as the [codesandbox example](https://ehlz3.csb.app/)
+
+## Releasing
+
+### Create a test release
+
+You can create a test release by posting the below comment in your pull request:
+
+```bash
+@excalibot trigger release
+```
+
+Once the version is released `@excalibot` will post a comment with the release version.
+
+### Creating a production release
+
+To release the next stable version follow the below steps:
+
+```bash
+yarn prerelease version
+```
+
+You need to pass the `version` for which you want to create the release. This will make the changes needed before making the release like updating `package.json`, `changelog` and more.
+
+The next step is to run the `release` script:
+
+```bash
+yarn release
+```
+
+This will publish the package.
+
+Right now there are two steps to create a production release but once this works fine these scripts will be combined and more automation will be done.
diff --git a/dev-docs/docs/@excalidraw/excalidraw/faq.mdx b/dev-docs/docs/@excalidraw/excalidraw/faq.mdx
new file mode 100644
index 000000000..4684d6c79
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/faq.mdx
@@ -0,0 +1,37 @@
+# FAQ
+
+### Does this package support collaboration ?
+
+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). Here is a [detailed answer](https://github.com/excalidraw/excalidraw/discussions/3879#discussioncomment-1110524) on how you can achieve the same.
+
+### Turning off Aggressive Anti-Fingerprinting in Brave browser
+
+When *Aggressive Anti-Fingerprinting* is turned on, the `measureText` API breaks which in turn breaks the Text Elements in your drawings. Here is more [info](https://github.com/excalidraw/excalidraw/pull/6336) on the same.
+
+We strongly recommend turning it off. You can follow the steps below on how to do so.
+
+
+1. Open [excalidraw.com](https://excalidraw.com) in Brave and click on the **Shield** button
+
+
+
+
+2. Once opened, look for **Aggressively Block Fingerprinting**
+
+
+
+3. Switch to **Block Fingerprinting**
+
+
+
+4. Thats all. All text elements should be fixed now 🎉
+
+
+
+If disabling this setting doesn't fix the display of text elements, please consider opening an [issue](https://github.com/excalidraw/excalidraw/issues/new) on our GitHub, or message us on [Discord](https://discord.gg/UexuTaE).
+
+
+
+## Need help?
+
+Check out the existing [Q&A](https://github.com/excalidraw/excalidraw/discussions?discussions_q=label%3Apackage%3Aexcalidraw). If you have any queries or need help, ask us [here](https://github.com/excalidraw/excalidraw/discussions?discussions_q=label%3Apackage%3Aexcalidraw).
diff --git a/dev-docs/docs/@excalidraw/excalidraw/installation.mdx b/dev-docs/docs/@excalidraw/excalidraw/installation.mdx
new file mode 100644
index 000000000..d8ddd59c3
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/installation.mdx
@@ -0,0 +1,43 @@
+# Installation
+
+**Excalidraw** is published to npm as a component you can directly embed in your projects.
+
+Using `npm`:
+
+```bash
+npm install react react-dom @excalidraw/excalidraw
+```
+
+or `yarn`:
+
+```bash
+yarn add react react-dom @excalidraw/excalidraw
+```
+
+:::tip
+
+**If you don't want to wait for the next stable release and try out the unreleased changes you can use `@excalidraw/excalidraw@next`.**
+
+:::
+
+### Static assets
+
+Excalidraw depends on assets such as localization files (if you opt to use them), fonts, and others.
+
+By default these assets are loaded from a public CDN [`https://unpkg.com/@excalidraw/excalidraw/dist/`](https://unpkg.com/@excalidraw/excalidraw/dist), so you don't need to do anything on your end.
+
+However, if you want to host these files yourself, you can find them in your `node_modules/@excalidraw/excalidraw/dist` directory, in folders `excalidraw-assets` (for production) and `excalidraw-assets-dev` (for development).
+
+Copy these folders to your static assets directory, and add a `window.EXCALIDRAW_ASSET_PATH` variable in your `index.html` or `index.js` entry file pointing to your public assets path (relative). For example, if you serve your assets from the root of your hostname, you would do:
+
+```js
+window.EXCALIDRAW_ASSET_PATH = "/";
+```
+
+### Dimensions of Excalidraw
+
+Excalidraw takes _100%_ of `width` and `height` of the containing block so make sure the container in which you render Excalidraw has non zero dimensions.
+
+### Demo
+
+[Try here](https://codesandbox.io/s/excalidraw-ehlz3).
diff --git a/dev-docs/docs/@excalidraw/excalidraw/integration.mdx b/dev-docs/docs/@excalidraw/excalidraw/integration.mdx
new file mode 100644
index 000000000..7080c32e9
--- /dev/null
+++ b/dev-docs/docs/@excalidraw/excalidraw/integration.mdx
@@ -0,0 +1,131 @@
+# Integration
+
+## Module bundler
+
+If you are using a module bundler (for instance, Webpack), you can import it as an ES6 module as shown below
+
+```js
+import { Excalidraw } from "@excalidraw/excalidraw";
+```
+
+:::info
+
+Throughout the documentation we use live, editable Excalidraw examples like the one shown below.
+
+While we aim for the examples to closely reflect what you'd get if you rendered it yourself, we actually initialize it with some props behind the scenes.
+For example, we're passing a `theme` prop to it based on the current color theme of the docs you're just reading.
+
+:::
+
+```jsx live
+function App() {
+ return (
+ <>
+
Excalidraw Example
+
+
+
+ >
+ );
+}
+```
+
+### Rendering Excalidraw only on client
+
+Since _Excalidraw_ doesn't support server side rendering, you should render the component once the host is `mounted`.
+
+The following worfklow shows one way how to render Excalidraw on Next.js. We'll add more detailed and alternative Next.js examples, soon.
+
+```jsx showLineNumbers
+import { useState, useEffect } from "react";
+export default function App() {
+ const [Excalidraw, setExcalidraw] = useState(null);
+ useEffect(() => {
+ import("@excalidraw/excalidraw").then((comp) => setExcalidraw(comp.Excalidraw));
+ }, []);
+ return <>{Excalidraw && }>;
+}
+```
+
+The `types` are available at `@excalidraw/excalidraw/types`, you can view [example for typescript](https://codesandbox.io/s/excalidraw-types-9h2dm)
+
+## Browser
+
+To use it in a browser directly:
+
+For development use :point_down:
+
+```js
+
+```
+
+For production use :point_down:
+
+```js
+
+```
+
+You will need to make sure `react`, `react-dom` is available as shown in the below example. For prod please use the production versions of `react`, `react-dom`.
+
+import Tabs from "@theme/Tabs";
+import TabItem from "@theme/TabItem";
+
+
+
+
+```html
+
+
+
+ Excalidraw in browser
+
+
+
+
+
+
+
+
+