diff --git a/.gitignore b/.gitignore index 237d68d..7c31eca 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ node_modules */build/* *.db data/ +.idea diff --git a/excalidraw b/excalidraw new file mode 160000 index 0000000..07944ad --- /dev/null +++ b/excalidraw @@ -0,0 +1 @@ +Subproject commit 07944ad9a2e59ee9d5f1a3b3718d1030b5a82b98 diff --git a/excalidraw/.codesandbox/Dockerfile b/excalidraw/.codesandbox/Dockerfile deleted file mode 100644 index fd5b38d..0000000 --- a/excalidraw/.codesandbox/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM node:18-bullseye - -# Vite wants to open the browser using `open`, so we -# need to install those utils. -RUN apt update -y && apt install -y xdg-utils diff --git a/excalidraw/.codesandbox/tasks.json b/excalidraw/.codesandbox/tasks.json deleted file mode 100644 index 51c6e4e..0000000 --- a/excalidraw/.codesandbox/tasks.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - // 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, - "preview": { - "port": 3000 - } - }, - "test": { - "name": "Run Tests", - "command": "yarn test", - "runAtStart": false - }, - "install-deps": { - "name": "Install Dependencies", - "command": "yarn install", - "restartOn": { - "files": ["yarn.lock"], - "branch": false, - "resume": false - } - } - } -} diff --git a/excalidraw/.dockerignore b/excalidraw/.dockerignore deleted file mode 100644 index 6472839..0000000 --- a/excalidraw/.dockerignore +++ /dev/null @@ -1,19 +0,0 @@ -* -!.env.development -!.env.production -!.eslintrc.json -!.npmrc -!.prettierrc -!excalidraw-app/ -!package.json -!public/ -!packages/ -!scripts/ -!tsconfig.json -!yarn.lock - -# keep (sub)sub directories at the end to exclude from explicit included -# e.g. ./packages/excalidraw/{dist,node_modules} -**/build -**/dist -**/node_modules diff --git a/excalidraw/.editorconfig b/excalidraw/.editorconfig deleted file mode 100644 index 9c7bca5..0000000 --- a/excalidraw/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -# http://EditorConfig.org - -# top-level EditorConfig file -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_size = 2 -indent_style = space -insert_final_newline = true -trim_trailing_whitespace = true diff --git a/excalidraw/.env.development b/excalidraw/.env.development deleted file mode 100644 index bf641c3..0000000 --- a/excalidraw/.env.development +++ /dev/null @@ -1,55 +0,0 @@ -MODE="development" - -VITE_APP_BACKEND_V2_GET_URL=https://json-dev.excalidraw.com/api/v2/ -VITE_APP_BACKEND_V2_POST_URL=https://json-dev.excalidraw.com/api/v2/post/ - -VITE_APP_LIBRARY_URL=https://libraries.excalidraw.com -VITE_APP_LIBRARY_BACKEND=https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries - -# collaboration WebSocket server (https://github.com/excalidraw/excalidraw-room) -VITE_APP_WS_SERVER_URL=http://localhost:3002 - -VITE_APP_PLUS_LP=https://plus.excalidraw.com -VITE_APP_PLUS_APP=http://localhost:3000 - -VITE_APP_AI_BACKEND=http://localhost:3015 - -VITE_APP_FIREBASE_CONFIG='{"apiKey":"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8","authDomain":"excalidraw-oss-dev.firebaseapp.com","projectId":"excalidraw-oss-dev","storageBucket":"excalidraw-oss-dev.appspot.com","messagingSenderId":"664559512677","appId":"1:664559512677:web:a385181f2928d328a7aa8c"}' - -# put these in your .env.local, or make sure you don't commit! -# must be lowercase `true` when turned on -# -# whether to disable live reload / HMR. Usuaully what you want to do when -# debugging Service Workers. -VITE_APP_DEV_DISABLE_LIVE_RELOAD= -VITE_APP_ENABLE_TRACKING=true - -FAST_REFRESH=false - -# The port the run the dev server -VITE_APP_PORT=3000 - -#Debug flags - -# To enable bounding box for text containers -VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX= - -# Set this flag to false if you want to open the overlay by default -VITE_APP_COLLAPSE_OVERLAY=true - -# Set this flag to false to disable eslint -VITE_APP_ENABLE_ESLINT=true - -# Enable PWA in dev server -VITE_APP_ENABLE_PWA=false - -VITE_APP_PLUS_EXPORT_PUBLIC_KEY='MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0 -7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij -ba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y -UNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD -s9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot -kdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS -HQIDAQAB' - -# set to true in .env.development.local to disable the prevent unload dialog -VITE_APP_DISABLE_PREVENT_UNLOAD= diff --git a/excalidraw/.env.production b/excalidraw/.env.production deleted file mode 100644 index 72dd24d..0000000 --- a/excalidraw/.env.production +++ /dev/null @@ -1,34 +0,0 @@ -MODE="production" - -VITE_APP_BACKEND_V2_GET_URL=https://json.excalidraw.com/api/v2/ -VITE_APP_BACKEND_V2_POST_URL=https://json.excalidraw.com/api/v2/post/ - -VITE_APP_LIBRARY_URL=https://libraries.excalidraw.com -VITE_APP_LIBRARY_BACKEND=https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries - -VITE_APP_PLUS_LP=https://plus.excalidraw.com -VITE_APP_PLUS_APP=https://app.excalidraw.com - -VITE_APP_AI_BACKEND=https://oss-ai.excalidraw.com - -# socket server URL used for collaboration -VITE_APP_WS_SERVER_URL=https://oss-collab.excalidraw.com - -VITE_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"}' - -VITE_APP_ENABLE_TRACKING=false - -VITE_APP_PLUS_EXPORT_PUBLIC_KEY='MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApQ0jM9Qz8TdFLzcuAZZX -/WvuKSOJxiw6AR/ZcE3eFQWM/mbFdhQgyK8eHGkKQifKzH1xUZjCxyXcxW6ZO02t -kPOPxhz+nxUrIoWCD/V4NGmUA1lxwHuO21HN1gzKrN3xHg5EGjyouR9vibT9VDGF -gq6+4Ic/kJX+AD2MM7Yre2+FsOdysrmuW2Fu3ahuC1uQE7pOe1j0k7auNP0y1q53 -PrB8Ts2LUpepWC1l7zIXFm4ViDULuyWXTEpUcHSsEH8vpd1tckjypxCwkipfZsXx -iPszy0o0Dx2iArPfWMXlFAI9mvyFCyFC3+nSvfyAUb2C4uZgCwAuyFh/ydPF4DEE -PQIDAQAB' - -# Set the below flags explicitly to false in production mode since vite loads and merges .env.local vars when running the build command -VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX=false -VITE_APP_COLLAPSE_OVERLAY=false -# Enable eslint in dev server -VITE_APP_ENABLE_ESLINT=false - diff --git a/excalidraw/.eslintignore b/excalidraw/.eslintignore deleted file mode 100644 index 8b4f458..0000000 --- a/excalidraw/.eslintignore +++ /dev/null @@ -1,11 +0,0 @@ -node_modules/ -build/ -package-lock.json -.vscode/ -firebase/ -dist/ -public/workbox -packages/excalidraw/types -examples/**/public -dev-dist -coverage diff --git a/excalidraw/.eslintrc.json b/excalidraw/.eslintrc.json deleted file mode 100644 index 89f8227..0000000 --- a/excalidraw/.eslintrc.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "extends": ["@excalidraw/eslint-config", "react-app"], - "rules": { - "import/order": [ - "warn", - { - "groups": ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"], - "pathGroups": [ - { - "pattern": "@excalidraw/**", - "group": "external", - "position": "after" - } - ], - "newlines-between": "always-and-inside-groups", - "warnOnUnassignedImports": true - } - ], - "import/no-anonymous-default-export": "off", - "no-restricted-globals": "off", - "@typescript-eslint/consistent-type-imports": [ - "error", - { - "prefer": "type-imports", - "disallowTypeAnnotations": false, - "fixStyle": "separate-type-imports" - } - ], - "no-restricted-imports": [ - "error", - { - "name": "jotai", - "message": "Do not import from \"jotai\" directly. Use our app-specific modules (\"editor-jotai\" or \"app-jotai\")." - } - ], - "react/jsx-no-target-blank": [ - "error", - { - "allowReferrer": true - } - ] - } -} diff --git a/excalidraw/.gitattributes b/excalidraw/.gitattributes deleted file mode 100644 index 6313b56..0000000 --- a/excalidraw/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto eol=lf diff --git a/excalidraw/.github/FUNDING.yml b/excalidraw/.github/FUNDING.yml deleted file mode 100644 index 6e86b8b..0000000 --- a/excalidraw/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -open_collective: excalidraw diff --git a/excalidraw/.github/assets/crowdin.svg b/excalidraw/.github/assets/crowdin.svg deleted file mode 100644 index 60fa841..0000000 --- a/excalidraw/.github/assets/crowdin.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/excalidraw/.github/assets/sentry.svg b/excalidraw/.github/assets/sentry.svg deleted file mode 100644 index d708783..0000000 --- a/excalidraw/.github/assets/sentry.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - diff --git a/excalidraw/.github/assets/vercel.svg b/excalidraw/.github/assets/vercel.svg deleted file mode 100644 index 3a73d90..0000000 --- a/excalidraw/.github/assets/vercel.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/excalidraw/.github/copilot-instructions.md b/excalidraw/.github/copilot-instructions.md deleted file mode 100644 index aebac52..0000000 --- a/excalidraw/.github/copilot-instructions.md +++ /dev/null @@ -1,45 +0,0 @@ -# Project coding standards - -## Generic Communication Guidelines - -- Be succint and be aware that expansive generative AI answers are costly and slow -- Avoid providing explanations, trying to teach unless asked for, your chat partner is an expert -- Stop apologising if corrected, just provide the correct information or code -- Prefer code unless asked for explanation -- Stop summarizing what you've changed after modifications unless asked for - -## TypeScript Guidelines - -- Use TypeScript for all new code -- Where possible, prefer implementations without allocation -- When there is an option, opt for more performant solutions and trade RAM usage for less CPU cycles -- Prefer immutable data (const, readonly) -- Use optional chaining (?.) and nullish coalescing (??) operators - -## React Guidelines - -- Use functional components with hooks -- Follow the React hooks rules (no conditional hooks) -- Keep components small and focused -- Use CSS modules for component styling - -## Naming Conventions - -- Use PascalCase for component names, interfaces, and type aliases -- Use camelCase for variables, functions, and methods -- Use ALL_CAPS for constants - -## Error Handling - -- Use try/catch blocks for async operations -- Implement proper error boundaries in React components -- Always log errors with contextual information - -## Testing - -- Always attempt to fix #problems -- Always offer to run `yarn test:app` in the project root after modifications are complete and attempt fixing the issues reported - -## Types - -- Always include `packages/math/src/types.ts` in the context when your write math related code and always use the Point type instead of { x, y} diff --git a/excalidraw/.github/workflows/autorelease-excalidraw.yml b/excalidraw/.github/workflows/autorelease-excalidraw.yml deleted file mode 100644 index 6e2c0d0..0000000 --- a/excalidraw/.github/workflows/autorelease-excalidraw.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Auto release excalidraw next -on: - push: - branches: - - release - -jobs: - Auto-release-excalidraw-next: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 2 - - name: Setup Node.js 18.x - uses: actions/setup-node@v2 - with: - node-version: 18.x - - name: Set up publish access - run: | - npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Auto release - run: | - yarn add @actions/core -W - yarn release --tag=next --non-interactive diff --git a/excalidraw/.github/workflows/build-docker.yml b/excalidraw/.github/workflows/build-docker.yml deleted file mode 100644 index f5f9b45..0000000 --- a/excalidraw/.github/workflows/build-docker.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Build Docker image - -on: - push: - branches: - - release - -jobs: - build-docker: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: docker build -t excalidraw . diff --git a/excalidraw/.github/workflows/cancel.yml b/excalidraw/.github/workflows/cancel.yml deleted file mode 100644 index e1ef216..0000000 --- a/excalidraw/.github/workflows/cancel.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Cancel previous runs - -on: - push: - branches: - - release - pull_request: - -jobs: - cancel: - runs-on: ubuntu-latest - timeout-minutes: 3 - steps: - - uses: styfle/cancel-workflow-action@0.6.0 - with: - workflow_id: 400555, 400556, 905313, 1451724, 1710116, 3185001, 3438604 - access_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/excalidraw/.github/workflows/lint.yml b/excalidraw/.github/workflows/lint.yml deleted file mode 100644 index 82f8263..0000000 --- a/excalidraw/.github/workflows/lint.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Lint - -on: pull_request - -jobs: - lint: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Setup Node.js 18.x - uses: actions/setup-node@v2 - with: - node-version: 18.x - - - name: Install and lint - run: | - yarn install - yarn test:other - yarn test:code - yarn test:typecheck diff --git a/excalidraw/.github/workflows/locales-coverage.yml b/excalidraw/.github/workflows/locales-coverage.yml deleted file mode 100644 index 957e9bc..0000000 --- a/excalidraw/.github/workflows/locales-coverage.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Build locales coverage - -on: - push: - branches: - - l10n_master - -jobs: - locales: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - token: ${{ secrets.PUSH_TRANSLATIONS_COVERAGE_PAT }} - - - name: Setup Node.js 18.x - uses: actions/setup-node@v2 - with: - node-version: 18.x - - - name: Create report file - run: | - yarn locales-coverage - FILE_CHANGED=$(git diff packages/excalidraw/locales/percentages.json) - if [ ! -z "${FILE_CHANGED}" ]; then - git config --global user.name 'Excalidraw Bot' - git config --global user.email 'bot@excalidraw.com' - git add packages/excalidraw/locales/percentages.json - git commit -am "Auto commit: Calculate translation coverage" - git push - fi - - name: Construct comment body - id: getCommentBody - run: | - body=$(npm run locales-coverage:description | grep '^[^>]') - body="${body//'%'/'%25'}" - body="${body//$'\n'/'%0A'}" - body="${body//$'\r'/'%0D'}" - echo ::set-output name=body::$body - - - name: Update description with coverage - uses: kt3k/update-pr-description@v1.0.1 - with: - pr_body: ${{ steps.getCommentBody.outputs.body }} - pr_title: "chore: Update translations from Crowdin" - github_token: ${{ secrets.PUSH_TRANSLATIONS_COVERAGE_PAT }} diff --git a/excalidraw/.github/workflows/publish-docker.yml b/excalidraw/.github/workflows/publish-docker.yml deleted file mode 100644 index 68eee27..0000000 --- a/excalidraw/.github/workflows/publish-docker.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Publish Docker - -on: - push: - branches: - - release - -jobs: - publish-docker: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: excalidraw/excalidraw:latest - platforms: linux/amd64, linux/arm64, linux/arm/v7 diff --git a/excalidraw/.github/workflows/semantic-pr-title.yml b/excalidraw/.github/workflows/semantic-pr-title.yml deleted file mode 100644 index 34a6413..0000000 --- a/excalidraw/.github/workflows/semantic-pr-title.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Semantic PR title - -on: - pull_request: - types: - - opened - - edited - - synchronize - -jobs: - semantic: - runs-on: ubuntu-latest - steps: - - uses: amannn/action-semantic-pull-request@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/excalidraw/.github/workflows/sentry-production.yml b/excalidraw/.github/workflows/sentry-production.yml deleted file mode 100644 index cea4cf6..0000000 --- a/excalidraw/.github/workflows/sentry-production.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: New Sentry production release - -on: - push: - branches: - - release - -jobs: - sentry: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Setup Node.js 18.x - uses: actions/setup-node@v2 - with: - node-version: 18.x - - name: Install and build - run: | - yarn --frozen-lockfile - yarn build:app - env: - CI: true - - name: Install Sentry - run: | - curl -sL https://sentry.io/get-cli/ | bash - - name: Create new Sentry release - run: | - export SENTRY_RELEASE=$(sentry-cli releases propose-version) - sentry-cli releases new $SENTRY_RELEASE --project $SENTRY_PROJECT - sentry-cli releases set-commits --auto $SENTRY_RELEASE - sentry-cli releases files $SENTRY_RELEASE upload-sourcemaps --no-rewrite ./build/static/js/ --url-prefix "~/static/js" - sentry-cli releases finalize $SENTRY_RELEASE - sentry-cli releases deploys $SENTRY_RELEASE new -e production - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_ORG: ${{ secrets.SENTRY_ORG }} - SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} diff --git a/excalidraw/.github/workflows/size-limit.yml b/excalidraw/.github/workflows/size-limit.yml deleted file mode 100644 index 5bd3c0d..0000000 --- a/excalidraw/.github/workflows/size-limit.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: "Bundle Size check @excalidraw/excalidraw" -on: - pull_request: - branches: - - master -jobs: - size: - runs-on: ubuntu-latest - env: - CI_JOB_NUMBER: 1 - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Setup Node.js 18.x - uses: actions/setup-node@v3 - with: - node-version: 18.x - - name: Install in packages/excalidraw - run: yarn - working-directory: packages/excalidraw - env: - CI: true - - uses: andresz1/size-limit-action@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - build_script: build:esm - skip_step: install - directory: packages/excalidraw diff --git a/excalidraw/.github/workflows/test-coverage-pr.yml b/excalidraw/.github/workflows/test-coverage-pr.yml deleted file mode 100644 index 7ff40ad..0000000 --- a/excalidraw/.github/workflows/test-coverage-pr.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Test Coverage PR -on: - pull_request: - -jobs: - coverage: - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write - - steps: - - uses: actions/checkout@v2 - - name: "Install Node" - uses: actions/setup-node@v2 - with: - node-version: "18.x" - - name: "Install Deps" - run: yarn install - - name: "Test Coverage" - run: yarn test:coverage - - name: "Report Coverage" - if: always() # Also generate the report if tests are failing - uses: davelosert/vitest-coverage-report-action@v2 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/excalidraw/.github/workflows/test.yml b/excalidraw/.github/workflows/test.yml deleted file mode 100644 index 7d454ec..0000000 --- a/excalidraw/.github/workflows/test.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Tests - -on: - push: - branches: master - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Setup Node.js 18.x - uses: actions/setup-node@v4 - with: - node-version: 18.x - - name: Install and test - run: | - yarn install - yarn test:app diff --git a/excalidraw/.gitignore b/excalidraw/.gitignore deleted file mode 100644 index 6f3a62b..0000000 --- a/excalidraw/.gitignore +++ /dev/null @@ -1,29 +0,0 @@ -.DS_Store -.env.development.local -.env.local -.env.production.local -.env.test.local -.envrc -.eslintcache -.history -.idea -.vercel -.vscode -.yarn -*.log -*.tgz -build -dist -firebase -logs -node_modules -npm-debug.log* -package-lock.json -yarn-debug.log* -yarn-error.log* -packages/excalidraw/types -coverage -dev-dist -html -meta*.json -.claude diff --git a/excalidraw/.husky/pre-commit b/excalidraw/.husky/pre-commit deleted file mode 100644 index ab2a5ac..0000000 --- a/excalidraw/.husky/pre-commit +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -# yarn lint-staged diff --git a/excalidraw/.lintstagedrc.js b/excalidraw/.lintstagedrc.js deleted file mode 100644 index 612d4c3..0000000 --- a/excalidraw/.lintstagedrc.js +++ /dev/null @@ -1,14 +0,0 @@ -const { CLIEngine } = require("eslint"); - -// see https://github.com/okonet/lint-staged#how-can-i-ignore-files-from-eslintignore- -// for explanation -const cli = new CLIEngine({}); - -module.exports = { - "*.{js,ts,tsx}": files => { - return ( - "eslint --max-warnings=0 --fix " + files.filter(file => !cli.isPathIgnored(file)).join(" ") - ); - }, - "*.{css,scss,json,md,html,yml}": ["prettier --write"], -}; diff --git a/excalidraw/.npmrc b/excalidraw/.npmrc deleted file mode 100644 index 1b78f1c..0000000 --- a/excalidraw/.npmrc +++ /dev/null @@ -1,2 +0,0 @@ -save-exact=true -legacy-peer-deps=true diff --git a/excalidraw/.nvmrc b/excalidraw/.nvmrc deleted file mode 100644 index 3c03207..0000000 --- a/excalidraw/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -18 diff --git a/excalidraw/.prettierignore b/excalidraw/.prettierignore deleted file mode 100644 index e69de29..0000000 diff --git a/excalidraw/.watchmanconfig b/excalidraw/.watchmanconfig deleted file mode 100644 index 0967ef4..0000000 --- a/excalidraw/.watchmanconfig +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/excalidraw/CLAUDE.md b/excalidraw/CLAUDE.md deleted file mode 100644 index 4faf291..0000000 --- a/excalidraw/CLAUDE.md +++ /dev/null @@ -1,34 +0,0 @@ -# CLAUDE.md - -## Project Structure - -Excalidraw is a **monorepo** with a clear separation between the core library and the application: - -- **`packages/excalidraw/`** - Main React component library published to npm as `@excalidraw/excalidraw` -- **`excalidraw-app/`** - Full-featured web application (excalidraw.com) that uses the library -- **`packages/`** - Core packages: `@excalidraw/common`, `@excalidraw/element`, `@excalidraw/math`, `@excalidraw/utils` -- **`examples/`** - Integration examples (NextJS, browser script) - -## Development Workflow - -1. **Package Development**: Work in `packages/*` for editor features -2. **App Development**: Work in `excalidraw-app/` for app-specific features -3. **Testing**: Always run `yarn test:update` before committing -4. **Type Safety**: Use `yarn test:typecheck` to verify TypeScript - -## Development Commands - -```bash -yarn test:typecheck # TypeScript type checking -yarn test:update # Run all tests (with snapshot updates) -yarn fix # Auto-fix formatting and linting issues -``` - -## Architecture Notes - -### Package System - -- Uses Yarn workspaces for monorepo management -- Internal packages use path aliases (see `vitest.config.mts`) -- Build system uses esbuild for packages, Vite for the app -- TypeScript throughout with strict configuration diff --git a/excalidraw/CONTRIBUTING.md b/excalidraw/CONTRIBUTING.md deleted file mode 100644 index 509908e..0000000 --- a/excalidraw/CONTRIBUTING.md +++ /dev/null @@ -1,3 +0,0 @@ -# Contributing - -Head over to the [docs](https://docs.excalidraw.com/docs/introduction/contributing) diff --git a/excalidraw/Dockerfile b/excalidraw/Dockerfile deleted file mode 100644 index c08385d..0000000 --- a/excalidraw/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM --platform=${BUILDPLATFORM} node:18 AS build - -WORKDIR /opt/node_app - -COPY . . - -# do not ignore optional dependencies: -# Error: Cannot find module @rollup/rollup-linux-x64-gnu -RUN --mount=type=cache,target=/root/.cache/yarn \ - npm_config_target_arch=${TARGETARCH} yarn --network-timeout 600000 - -ARG NODE_ENV=production - -RUN npm_config_target_arch=${TARGETARCH} yarn build:app:docker - -FROM --platform=${TARGETPLATFORM} nginx:1.27-alpine - -COPY --from=build /opt/node_app/excalidraw-app/build /usr/share/nginx/html - -HEALTHCHECK CMD wget -q -O /dev/null http://localhost || exit 1 diff --git a/excalidraw/LICENSE b/excalidraw/LICENSE deleted file mode 100644 index 8a844bc..0000000 --- a/excalidraw/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Excalidraw - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/excalidraw/README.md b/excalidraw/README.md deleted file mode 100644 index f1cf030..0000000 --- a/excalidraw/README.md +++ /dev/null @@ -1,130 +0,0 @@ - - - - Excalidraw - - - -

- Excalidraw Editor | - Blog | - Documentation | - Excalidraw+ -

- -
-

- An open source virtual hand-drawn style whiteboard.
- Collaborative and end-to-end encrypted.
-
-

-
- -
-

- - Excalidraw is released under the MIT license. - - - npm downloads/month - - - PRs welcome! - - - Chat on Discord - - - Ask DeepWiki - - - Follow Excalidraw on Twitter - -

- -
-
- - Product showcase - -
-

- Create beautiful hand-drawn like diagrams, wireframes, or whatever you like. -

-
-
-
- -## Features - -The Excalidraw editor (npm package) supports: - -- 💯 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. - -## 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/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 - -**Note:** following instructions are for installing the Excalidraw [npm package](https://www.npmjs.com/package/@excalidraw/excalidraw) when integrating Excalidraw into your own app. To run the repository locally for development, please refer to our [Development Guide](https://docs.excalidraw.com/docs/introduction/development). - -Use `npm` or `yarn` to install the package. - -```bash -npm install react react-dom @excalidraw/excalidraw -# or -yarn add react react-dom @excalidraw/excalidraw -``` - -Check out our [documentation](https://docs.excalidraw.com/docs/@excalidraw/excalidraw/installation) for more details! - -## 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: - -[![Vercel](./.github/assets/vercel.svg)](https://vercel.com) [![Sentry](./.github/assets/sentry.svg)](https://sentry.io) [![Crowdin](./.github/assets/crowdin.svg)](https://crowdin.com) diff --git a/excalidraw/crowdin.yml b/excalidraw/crowdin.yml deleted file mode 100644 index ccb8a17..0000000 --- a/excalidraw/crowdin.yml +++ /dev/null @@ -1,3 +0,0 @@ -files: - - source: /packages/excalidraw/locales/en.json - translation: /packages/excalidraw/locales/%locale%.json diff --git a/excalidraw/dev-docs/.gitignore b/excalidraw/dev-docs/.gitignore deleted file mode 100644 index b2d6de3..0000000 --- a/excalidraw/dev-docs/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -# Dependencies -/node_modules - -# Production -/build - -# Generated files -.docusaurus -.cache-loader - -# Misc -.DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local - -npm-debug.log* -yarn-debug.log* -yarn-error.log* diff --git a/excalidraw/dev-docs/README.md b/excalidraw/dev-docs/README.md deleted file mode 100644 index aaba2fa..0000000 --- a/excalidraw/dev-docs/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# Website - -This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. - -### Installation - -``` -$ yarn -``` - -### Local Development - -``` -$ yarn start -``` - -This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. - -### Build - -``` -$ yarn build -``` - -This command generates static content into the `build` directory and can be served using any static contents hosting service. - -### Deployment - -Using SSH: - -``` -$ USE_SSH=true yarn deploy -``` - -Not using SSH: - -``` -$ GIT_USER= yarn deploy -``` - -If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. diff --git a/excalidraw/dev-docs/babel.config.js b/excalidraw/dev-docs/babel.config.js deleted file mode 100644 index bfd75db..0000000 --- a/excalidraw/dev-docs/babel.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - presets: [require.resolve("@docusaurus/core/lib/babel/preset")], -}; diff --git a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/api-intro.mdx b/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/api-intro.mdx deleted file mode 100644 index aee7f3b..0000000 --- a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/api-intro.mdx +++ /dev/null @@ -1,11 +0,0 @@ ---- -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/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/children-components-intro.mdx b/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/children-components-intro.mdx deleted file mode 100644 index 06bb1cb..0000000 --- a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/children-components-intro.mdx +++ /dev/null @@ -1,22 +0,0 @@ ---- -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) -- [Sidebar](/docs/@excalidraw/excalidraw/api/children-components/sidebar) -- [Footer](/docs/@excalidraw/excalidraw/api/children-components/footer) -- [LiveCollaborationTrigger](/docs/@excalidraw/excalidraw/api/children-components/live-collaboration-trigger) diff --git a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/footer.mdx b/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/footer.mdx deleted file mode 100644 index e7852ce..0000000 --- a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/footer.mdx +++ /dev/null @@ -1,68 +0,0 @@ -# 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 be a valid React Node. - -**Usage** - -```jsx live -function App() { - return ( -
- -
- -
-
-
- ); -} -``` - -This will only work 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.editor.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(); -``` diff --git a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/live-collaboration-trigger.mdx b/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/live-collaboration-trigger.mdx deleted file mode 100644 index ef74d0e..0000000 --- a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/live-collaboration-trigger.mdx +++ /dev/null @@ -1,62 +0,0 @@ -# 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 -

- - setExcalidrawAPI(api)} - renderTopRightUI={() => ( - { - window.alert("You clicked on collab button"); - setIsCollaborating(true); - }} - /> - )} - > -
- ); -} -``` diff --git a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/main-menu.mdx b/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/main-menu.mdx deleted file mode 100644 index b0062d9..0000000 --- a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/main-menu.mdx +++ /dev/null @@ -1,169 +0,0 @@ -# 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 ( -
- - - window.alert("Item1")}> - Item1 - - window.alert("Item2")}> - Item 2 - - - -
- ); -} -``` - -### `` - -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. | -| `selected` | `boolean` | No | `false` | Whether item is active | -| `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. | -| `selected` | `boolean` | No | `false` | Whether item is active | -| `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 ( -
- - - - - window.alert("Item1")}> - Item1 - - window.alert("Item2")}> - Item 2 - - - -
- ); -} -``` - -Here is a [complete list](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/components/main-menu/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 ( -
- - - - - - - - window.alert("Item1")}> - Item1 - - window.alert("Item2")}> - Item 2 - - - - -
- ); -} -``` - -| Prop | Type | Required | Default | Description | -| --- | --- | :-: | :-: | --- | -| `children ` | `React.ReactNode` | Yes | - | The content of the `Menu Group` | diff --git a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/sidebar.mdx b/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/sidebar.mdx deleted file mode 100644 index ed12f64..0000000 --- a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/sidebar.mdx +++ /dev/null @@ -1,129 +0,0 @@ -# Sidebar - -The editor comes with a default sidebar on the right in LTR (Left to Right) mode which contains the library. You can also add your own custom sidebar(s) by rendering this component as a child of ``. - -## Props - -| Prop | Type | Required | Description | -| --- | --- | --- | --- | -| `name` | `string` | Yes | Sidebar name that uniquely identifies it. | -| `children` | `React.ReactNode` | Yes | Content you want to render inside the sidebar. | -| `onStateChange` | `(state: AppState["openSidebar"]) => void` | No | Invoked on open/close or tab change. No need to act on this event, as the editor manages the sidebar open state on its own. | -| `onDock` | `(docked: boolean) => void` | No | Invoked when the user toggles the `dock` button. Passed the current docked state. | -| `docked` | `boolean` | No | Indicates whether the sidebar is `docked`. By default, the sidebar is `undocked`. If passed, the docking becomes controlled. | -| `className` | `string` | No | | -| `style` | `React.CSSProperties` | No | | - -At minimum, each sidebar needs to have a unique `name` prop, and render some content inside it, which can be either composed from the exported sidebar sub-components, or custom elements. - -Unless `docked={true}` is passed, the sidebar will close when the user clicks outside of it. It can also be closed using the close button in the header, if you render the `` component. - -Further, if the sidebader doesn't comfortably fit in the editor, it won't be dockable. To decide the breakpoint for docking you can use [UIOptions.dockedSidebarBreakpoint](/docs/@excalidraw/excalidraw/api/props/ui-options#dockedsidebarbreakpoint). - -To make your sidebar user-dockable, you need to supply `props.docked` (current docked state) alongside `props.onDock` callback (to listen for and handle docked state changes). The component doesn't track local state for the `docked` prop, so you need to manage it yourself. - -## Sidebar.Header - -| Prop | Type | Required | Description | -| --- | --- | --- | --- | -| `children` | `React.ReactNode` | No | Content you want to render inside the sidebar header next to the `close` / `dock` buttons. | -| `className` | `string` | No | | - -Renders a sidebar header which contains a close button, and a dock button (when applicable). You can also render custom content in addition. - -Can be nested inside specific tabs, or rendered as direct child of `` for the whole sidebar component. - -## Sidebar.Tabs - -| Prop | Type | Required | Description | -| ---------- | ----------------- | -------- | ------------------------------ | -| `children` | `React.ReactNode` | No | Container for individual tabs. | - -Sidebar may contain inner tabs. Each `` must be rendered inside this `` container component. - -## Sidebar.Tab - -| Prop | Type | Required | Description | -| ---------- | ----------------- | -------- | ---------------- | -| `tab` | `string` | Yes | Unique tab name. | -| `children` | `React.ReactNode` | No | Tab content. | - -Content of a given sidebar tab. It must be rendered inside ``. - -## Sidebar.TabTriggers - -| Prop | Type | Required | Description | -| --- | --- | --- | --- | -| `children` | `React.ReactNode` | No | Container for individual tab triggers. | - -Container component for tab trigger buttons to switch between tabs. - -## Sidebar.TabTrigger - -| Prop | Type | Required | Description | -| --- | --- | --- | --- | -| `tab` | `string` | Yes | Tab name to toggle. | -| `children` | `React.ReactNode` | No | Tab trigger content, such as a label. | - -A given tab trigger button that switches to a given sidebar tab. It must be rendered inside ``. - -## Sidebar.Trigger - -| Prop | Type | Required | Description | -| --- | --- | --- | --- | -| `name` | `string` | Yes | Sidebar name the trigger will control. | -| `tab` | `string` | No | Optional tab to open. | -| `onToggle` | `(open: boolean) => void` | No | Callback invoked on toggle. | -| `title` | `string` | No | A11y title. | -| `children` | `React.ReactNode` | No | Content (usually label) you want to render inside the button. | -| `icon` | `JSX.Element` | No | Trigger icon if any. | -| `className` | `string` | No | | -| `style` | `React.CSSProperties` | No | | - -You can use the [`ref.toggleSidebar({ name: "custom" })`](/docs/@excalidraw/excalidraw/api/props/excalidraw-api#toggleSidebar) api to control the sidebar, but we export a trigger button to make UI use cases easier. - -## Example - -```tsx live -function App() { - const [docked, setDocked] = useState(false); - - return ( -
- - - - - Tab one! - Tab two! - - One - Two - - - - -
- - Toggle Custom Sidebar - -
-
-
- ); -} -``` diff --git a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/welcome-screen.mdx b/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/welcome-screen.mdx deleted file mode 100644 index 8834870..0000000 --- a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/children-components/welcome-screen.mdx +++ /dev/null @@ -1,140 +0,0 @@ -# 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). - -Excalidraw logo: Sketch hand-drawn like diagrams. - -### 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 ( -
- - - - - - Welcome Screen Heading! - - - - Excalidraw GitHub - - - - - - -
- ); -} -``` - -#### 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/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/constants.mdx b/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/constants.mdx deleted file mode 100644 index 36fbfa7..0000000 --- a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/constants.mdx +++ /dev/null @@ -1,46 +0,0 @@ -# Constants - -### FONT_FAMILY - -**How to use** - -```js -import { FONT_FAMILY } from "@excalidraw/excalidraw"; -``` - -`FONT_FAMILY` contains all the font families used in `Excalidraw`. The default families are the following: - -| Font Family | Description | -| ----------- | ---------------------- | -| `Excalifont` | The `Hand-drawn` font | -| `Nunito` | The `Normal` Font | -| `Comic Shanns` | The `Code` Font | - -Pre-selected family is `FONT_FAMILY.Excalifont`, unless it's overriden with `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/packages/excalidraw/constants.ts#L101) contains all the mime types supported by `Excalidraw`. - -**How to use ** - -```js -import { MIME_TYPES } from "@excalidraw/excalidraw"; -``` diff --git a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/excalidraw-element-skeleton.mdx b/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/excalidraw-element-skeleton.mdx deleted file mode 100644 index b633236..0000000 --- a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/excalidraw-element-skeleton.mdx +++ /dev/null @@ -1,475 +0,0 @@ -# Creating Elements programmatically - -We support a simplified API to make it easier to generate Excalidraw elements programmatically. This API is in beta and subject to change before stable. You can check the [PR](https://github.com/excalidraw/excalidraw/pull/6546) for more details. - -For this purpose we introduced a new type [`ExcalidrawElementSkeleton`](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/data/transform.ts#L133). This is the simplified version of [`ExcalidrawElement`](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/element/types.ts#L134) type with the minimum possible attributes so that creating elements programmatically is much easier (especially for cases like binding arrows or creating text containers). - -The [`ExcalidrawElementSkeleton`](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/data/transform.ts#L133) can be converted to fully qualified Excalidraw elements by using [`convertToExcalidrawElements`](/docs/@excalidraw/excalidraw/api/excalidraw-element-skeleton#converttoexcalidrawelements). - -## convertToExcalidrawElements - -**_Signature_** - -```ts -convertToExcalidrawElements( - elements: ExcalidrawElementSkeleton, - opts?: { regenerateIds: boolean } -): ExcalidrawElement[] -``` - -| Name | Type | Default | Description | -| --- | --- | --- | --- | -| `elements` | [ExcalidrawElementSkeleton](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/data/transform.ts#L137) | | The Excalidraw element Skeleton which needs to be converted to Excalidraw elements. | -| `opts` | `{ regenerateIds: boolean }` | ` {regenerateIds: true}` | By default `id` will be regenerated for all the elements irrespective of whether you pass the `id` so if you don't want the ids to regenerated, you can set this attribute to `false`. | - -**_How to use_** - -```js -import { convertToExcalidrawElements } from "@excalidraw/excalidraw"; -``` - -This function converts the Excalidraw Element Skeleton to excalidraw elements which could be then rendered on the canvas. Hence calling this function is necessary before passing it to APIs like [`initialData`](https://docs.excalidraw.com/docs/@excalidraw/excalidraw/api/props/initialdata), [`updateScene`](https://docs.excalidraw.com/docs/@excalidraw/excalidraw/api/props/excalidraw-api#updatescene) if you are using the Skeleton API - -## Supported Features - -### Rectangle, Ellipse, and Diamond - -To create these shapes you need to pass its `type` and `x` and `y` coordinates for position. The rest of the attributes are optional\_. - -For the Skeleton API to work, `convertToExcalidrawElements` needs to be called before passing it to Excalidraw Component via initialData, updateScene or any such API. - -```jsx live -function App() { - const elements = convertToExcalidrawElements([ - { - type: "rectangle", - x: 100, - y: 250, - }, - { - type: "ellipse", - x: 250, - y: 250, - }, - { - type: "diamond", - x: 380, - y: 250, - }, - ]); - return ( -
- -
- ); -} -``` - -You can pass additional [`properties`](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/element/types.ts#L27) as well to decorate the shapes. - -:::info - -You can copy the below test examples and replace the elements in the live editor above to test it out. - -::: - -```js -convertToExcalidrawElements([ - { - type: "rectangle", - x: 50, - y: 250, - width: 200, - height: 100, - backgroundColor: "#c0eb75", - strokeWidth: 2, - }, - { - type: "ellipse", - x: 300, - y: 250, - width: 200, - height: 100, - backgroundColor: "#ffc9c9", - strokeStyle: "dotted", - fillStyle: "solid", - strokeWidth: 2, - }, - { - type: "diamond", - x: 550, - y: 250, - width: 200, - height: 100, - backgroundColor: "#a5d8ff", - strokeColor: "#1971c2", - strokeStyle: "dashed", - fillStyle: "cross-hatch", - strokeWidth: 2, - }, -]); -``` - -![image](https://github.com/excalidraw/excalidraw/assets/11256141/70ca7063-88fb-434c-838a-cd466e1bc3c2) - -### Text Element - -The `type`, `x`, `y` and `text` properties are required to create a text element, rest of the attributes are optional - -```js -convertToExcalidrawElements([ - { - type: "text", - x: 100, - y: 100, - text: "HELLO WORLD!", - }, - { - type: "text", - x: 100, - y: 150, - text: "STYLED HELLO WORLD!", - fontSize: 20, - strokeColor: "#5f3dc4", - }, -]); -``` - -![image](https://github.com/excalidraw/excalidraw/assets/11256141/085c7ac3-7952-4f22-b9c3-6beb51438526) - -### Lines and Arrows - -The `type`, `x`, and `y` properties are required, rest of the attributes are optional - -```js -convertToExcalidrawElements([ - { - type: "arrow", - x: 100, - y: 20, - }, - { - type: "line", - x: 100, - y: 60, - }, -]); -``` - -![image](https://github.com/excalidraw/excalidraw/assets/11256141/0c22a06b-b568-4ab5-9848-a5f0160f66a6) - -#### With Addtional properties - -```js -convertToExcalidrawElements([ - { - type: "arrow", - x: 450, - y: 20, - startArrowhead: "dot", - endArrowhead: "triangle", - strokeColor: "#1971c2", - strokeWidth: 2, - }, - { - type: "line", - x: 450, - y: 60, - strokeColor: "#2f9e44", - strokeWidth: 2, - strokeStyle: "dotted", - }, -]); -``` - -![image](https://github.com/excalidraw/excalidraw/assets/11256141/14f1bf3f-ad81-4096-8c1c-f35235084ec5) - -### Text Containers - -In addition to `type`, `x` and `y` properties, [`label`](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/data/transform.ts#L124C7-L130C59) property is required for text containers. The `text` property in `label` is required, rest of the attributes are optional. - -If you don't provide the dimensions of container, we calculate it based of the label dimensions. - -```js -convertToExcalidrawElements([ - { - type: "rectangle", - x: 300, - y: 290, - label: { - text: "RECTANGLE TEXT CONTAINER", - }, - }, - { - type: "ellipse", - x: 500, - y: 100, - label: { - text: "ELLIPSE\n TEXT CONTAINER", - }, - }, - { - type: "diamond", - x: 100, - y: 100, - label: { - text: "DIAMOND\nTEXT CONTAINER", - }, - }, -]); -``` - -![image](https://github.com/excalidraw/excalidraw/assets/11256141/1e2c7b5d-fcb4-4f86-946d-0bfb0e97d532) - -#### With Additional properties - -```js -convertToExcalidrawElements([ - { - type: "diamond", - x: -120, - y: 100, - width: 270, - backgroundColor: "#fff3bf", - strokeWidth: 2, - label: { - text: "STYLED DIAMOND TEXT CONTAINER", - strokeColor: "#099268", - fontSize: 20, - }, - }, - { - type: "rectangle", - x: 180, - y: 150, - width: 200, - strokeColor: "#c2255c", - label: { - text: "TOP LEFT ALIGNED RECTANGLE TEXT CONTAINER", - textAlign: "left", - verticalAlign: "top", - fontSize: 20, - }, - }, - { - type: "ellipse", - x: 400, - y: 130, - strokeColor: "#f08c00", - backgroundColor: "#ffec99", - width: 200, - label: { - text: "STYLED ELLIPSE TEXT CONTAINER", - strokeColor: "#c2255c", - }, - }, -]); -``` - -![image](https://github.com/excalidraw/excalidraw/assets/11256141/f8123cd1-c9aa-452d-b96b-05c846c5030d) - -### Labelled Arrows - -Similar to Text Containers, you can create labelled arrows as well. - -```js -convertToExcalidrawElements([ - { - type: "arrow", - x: 100, - y: 100, - label: { - text: "LABELED ARROW", - }, - }, - { - type: "arrow", - x: 100, - y: 200, - label: { - text: "STYLED LABELED ARROW", - strokeColor: "#099268", - fontSize: 20, - }, - }, - { - type: "arrow", - x: 100, - y: 300, - strokeColor: "#1098ad", - strokeWidth: 2, - label: { - text: "ANOTHER STYLED LABELLED ARROW", - }, - }, - { - type: "arrow", - x: 100, - y: 400, - strokeColor: "#1098ad", - strokeWidth: 2, - label: { - text: "ANOTHER STYLED LABELLED ARROW", - strokeColor: "#099268", - }, - }, -]); -``` - -![image](https://github.com/excalidraw/excalidraw/assets/11256141/70635e9b-f1c8-4839-89e1-73b813abeb93) - -### Arrow bindings - -To bind arrow to a shape you need to specify its [`start`](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/data/transform.ts#L86) and [`end`](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/data/transform.ts#L54) properties. You need to pass either `type` or `id` property in `start` and `end` properties, rest of the attributes are optional - -```js -convertToExcalidrawElements([ - { - type: "arrow", - x: 255, - y: 239, - label: { - text: "HELLO WORLD!!", - }, - start: { - type: "rectangle", - }, - end: { - type: "ellipse", - }, - }, -]); -``` - -When position for `start` and `end ` properties are not specified, we compute it according to arrow position. - -![image](https://github.com/excalidraw/excalidraw/assets/11256141/5aff09fd-b7e8-4c63-98be-da40b0698704) - -```js -convertToExcalidrawElements([ - { - type: "arrow", - x: 255, - y: 239, - label: { - text: "HELLO WORLD!!", - }, - start: { - type: "text", - text: "HEYYYYY", - }, - end: { - type: "text", - text: "WHATS UP ?", - }, - }, -]); -``` - -![image](https://github.com/excalidraw/excalidraw/assets/11256141/2a9f03ac-e45c-4fbd-9be0-5d9f8c8e0343) - -#### When passing `id` - -Useful when you want to bind multiple arrows to one diagram / use some existing diagram - -```js -convertToExcalidrawElements([ - { - type: "ellipse", - id: "ellipse-1", - strokeColor: "#66a80f", - x: 390, - y: 356, - width: 150, - height: 150, - backgroundColor: "#d8f5a2", - }, - { - type: "diamond", - id: "diamond-1", - strokeColor: "#9c36b5", - width: 100, - x: -30, - y: 380, - }, - { - type: "arrow", - x: 100, - y: 440, - width: 295, - height: 35, - strokeColor: "#1864ab", - start: { - type: "rectangle", - width: 150, - height: 150, - }, - end: { - id: "ellipse-1", - }, - }, - { - type: "arrow", - x: 60, - y: 420, - width: 330, - strokeColor: "#e67700", - start: { - id: "diamond-1", - }, - end: { - id: "ellipse-1", - }, - }, -]); -``` - -![image](https://github.com/excalidraw/excalidraw/assets/11256141/a8b047c8-2eed-4aea-82a2-e1e6bbddb8d4) - -### Frames - -To create a frame, you need to pass `type`, `children` (list of Excalidraw element ids). The rest of the attributes are optional. - -```ts -{ - type: "frame"; - children: readonly ExcalidrawElement["id"][]; - name?: string; - } & Partial); -``` - -```ts -convertToExcalidrawElements([ - { - "type": "rectangle", - "x": 10, - "y": 10, - "strokeWidth": 2, - "id": "1" - }, - { - "type": "diamond", - "x": 120, - "y": 20, - "backgroundColor": "#fff3bf", - "strokeWidth": 2, - "label": { - "text": "HELLO EXCALIDRAW", - "strokeColor": "#099268", - "fontSize": 30 - }, - "id": "2" - }, - { - "type": "frame", - "children": ["1", "2"], - "name": "My frame" - }] -} -``` diff --git a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/props/excalidraw-api.mdx b/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/props/excalidraw-api.mdx deleted file mode 100644 index c9580b6..0000000 --- a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/props/excalidraw-api.mdx +++ /dev/null @@ -1,449 +0,0 @@ -# excalidrawAPI - -
-  (api:{" "}
-  
-    ExcalidrawAPI
-  
-  ) => void;
-
- -Once the callback is triggered, you will need to store the api in state to access it later. - -```jsx showLineNumbers -export default function App() { - const [excalidrawAPI, setExcalidrawAPI] = useState(null); - return setExcalidrawAPI(api)} />; -} -``` - -You can use this prop when you want to access some [Excalidraw APIs](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/types.ts#L616). We expose the below APIs :point_down: - -| API | Signature | Usage | -| --- | --- | --- | -| [updateScene](#updatescene) | `function` | updates the scene with the sceneData | -| [updateLibrary](#updatelibrary) | `function` | updates the library | -| [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 | -| [toggleSidebar](#toggleSidebar) | `function` | Toggles specific sidebar on/off | -| [onChange](#onChange) | `function` | Subscribes to change events | -| [onPointerDown](#onPointerDown) | `function` | Subscribes to `pointerdown` events | -| [onPointerUp](#onPointerUp) | `function` | Subscribes to `pointerup` events | - -:::info The `Ref` support has been removed in v0.17.0 so if you are using refs, please update the integration to use the `excalidrawAPI`. - -Additionally `ready` and `readyPromise` from the API have been discontinued. These APIs were found to be superfluous, and as part of the effort to streamline the APIs and maintain simplicity, they were removed in version v0.17.0. - -::: - -## updateScene - -
-  (scene:{" "}
-  
-    sceneData
-  
-  ) => void
-
- -You can use this function to update the scene with the sceneData. It accepts the below attributes. - -| Name | Type | Description | -| --- | --- | --- | -| `elements` | [`ImportedDataState["elements"]`](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/data/types.ts#L38) | The `elements` to be updated in the scene | -| `appState` | [`ImportedDataState["appState"]`](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/data/types.ts#L39) | The `appState` to be updated in the scene. | -| `collaborators` | MapCollaborator> | The list of collaborators to be updated in the scene. | -| `captureUpdate` | [`CaptureUpdateAction`](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/store.ts#L40) | Controls which updates should be captured by the `Store`. Captured updates are emmitted and listened to by other components, such as `History` for undo / redo purposes. | - -```jsx live -function App() { - const updateScene = () => { - const sceneData = { - elements: [ - { - type: "rectangle", - version: 141, - versionNonce: 361174001, - isDeleted: false, - id: "oDVXy8D6rom3H1-LLH2-f", - fillStyle: "hachure", - strokeWidth: 1, - strokeStyle: "solid", - roughness: 1, - opacity: 100, - angle: 0, - x: 100.50390625, - y: 93.67578125, - strokeColor: "#c92a2a", - backgroundColor: "transparent", - width: 186.47265625, - height: 141.9765625, - seed: 1968410350, - groupIds: [], - boundElements: null, - locked: false, - link: null, - updated: 1, - roundness: { - type: 3, - value: 32, - }, - }, - ], - appState: { - viewBackgroundColor: "#edf2ff", - }, - captureUpdate: CaptureUpdateAction.IMMEDIATELY, - }; - excalidrawAPI.updateScene(sceneData); - }; - const [excalidrawAPI, setExcalidrawAPI] = useState(null); - return ( -
-

Click to update the scene

- - setExcalidrawAPI(api)} /> -
- ); -} -``` - -#### captureUpdate - -You can use the `captureUpdate` to influence undo / redo behaviour. - -> **NOTE**: Some updates are not observed by the store / history - i.e. updates to `collaborators` object or parts of `AppState` which are not observed (not `ObservedAppState`). Such updates will never make it to the undo / redo stacks, regardless of the passed `captureUpdate` value. - -| | `captureUpdate` value | Notes | -| --- | --- | --- | -| _Immediately undoable_ | `CaptureUpdateAction.IMMEDIATELY` | Use for updates which should be captured. Should be used for most of the local updates. These updates will _immediately_ make it to the local undo / redo stacks. | -| _Eventually undoable_ | `CaptureUpdateAction.EVENTUALLY` | Use for updates which should not be captured immediately - likely exceptions which are part of some async multi-step process. Otherwise, all such updates would end up being captured with the next `CaptureUpdateAction.IMMEDIATELY` - triggered either by the next `updateScene` or internally by the editor. These updates will _eventually_ make it to the local undo / redo stacks. | -| _Never undoable_ | `CaptureUpdateAction.NEVER` | Use for updates which should never be recorded, such as remote updates or scene initialization. These updates will _never_ make it to the local undo / redo stacks. | - -### updateLibrary - -
-  (opts: { 
libraryItems:{" "} - - LibraryItemsSource - - ;
merge?: boolean;
prompt?: boolean; -
openLibraryMenu?: boolean; -
defaultStatus?: "unpublished" | "published";
}) => Promise< - - LibraryItems - - > -
- -You can use this function to update the library. It accepts the below attributes. - -| Name | Type | Default | Description | -| --- | --- | --- | --- | -| `libraryItems` | [LibraryItemsSource](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/types.ts#L249) | \_ | The `libraryItems` to be replaced/merged with current library | -| `merge` | boolean | `false` | Whether to merge with existing library items. | -| `prompt` | boolean | `false` | Whether to prompt user for confirmation. | -| `openLibraryMenu` | boolean | `false` | Keep the library menu open after library is updated. | -| `defaultStatus` | "unpublished" | "published" | `"unpublished"` | Default library item's `status` if not present. | - -```tsx live -function App() { - const [excalidrawAPI, setExcalidrawAPI] = useState(null); - - useEffect(() => { - if (!excalidrawAPI) { - return; - } - // to open the library sidebar - excalidrawAPI.updateScene({ appState: { openSidebar: "library" } }); - }, [excalidrawAPI]); - - return ( -
-

Click to update the library items

- - setExcalidrawAPI(api)} - // initial data retrieved from https://github.com/excalidraw/excalidraw/blob/master/dev-docs/packages/excalidraw/initialData.js - initialData={{ - libraryItems: initialData.libraryItems, - appState: { openSidebar: "library" }, - }} - /> -
- ); -} -``` - -### addFiles - -
-  (files:{" "}
-  
-    BinaryFileData
-  
-  ) => void
-
- -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 - -
-  () =>{" "}
-  
-    ExcalidrawElement[]
-  
-
- -Returns all the elements including the deleted in the scene. - -## getSceneElements - -
-  () => NonDeleted<
-  
-    ExcalidrawElement
-  
-  []>
-
- -Returns all the elements excluding the deleted in the scene - -## getAppState - -
-  () =>{" "}
-  
-    AppState
-  
-
- -Returns current appState. - -## history - -```tsx -{ - clear: () => void -} -``` - -This is the history API. history.clear() will clear the history. - -## scrollToContent - -```tsx -( - target?: ExcalidrawElement | ExcalidrawElement[], - opts?: - | { - fitToContent?: boolean; - animate?: boolean; - duration?: number; - } - | { - fitToViewport?: boolean; - viewportZoomFactor?: number; - animate?: boolean; - duration?: number; - } -) => void -``` - -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](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/element/types.ts#L115) | [ExcalidrawElement[]](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/element/types.ts#L115) | 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. Note that the zoom range is between 10%-100%. | -| opts.fitToViewport | boolean | false | Similar to fitToContent but the zoom range is not limited. If elements are smaller than the viewport, zoom will go above 100%. | -| opts.viewportZoomFactor | number | 0.7 | when fitToViewport=true, how much screen should the content cover, between 0.1 (10%) and 1 (100%) | -| 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 - -
-  () =>{" "}
-  
-    files
-  
-
- -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. - -```ts -( - tool: ( - | { type: ToolType } - | { type: "custom"; customType: string } - ) & { locked?: boolean }, -) => {}; -``` - -| Name | Type | Default | Description | -| --- | --- | --- | --- | -| `type` | [ToolType](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/types.ts#L91) | `selection` | The tool type which should be set as active tool | -| `locked` | `boolean` | `false` | Indicates whether the the active tool should be locked. It behaves the same way when using the `lock` tool in the editor interface | - -## 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 -``` - -## toggleSidebar - -```tsx -(opts: { name: string; tab?: string; force?: boolean }) => boolean; -``` - -This API can be used to toggle sidebar, optionally opening a specific sidebar tab. It returns whether the sidebar was toggled on or off. If the `force` flag passed, it will force the sidebar to be toggled either on/off. - -This API is especially useful when you render a custom [``](/docs/@excalidraw/excalidraw/api/children-components/sidebar), 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. - -## onChange - -```tsx -( - callback: ( - elements: readonly ExcalidrawElement[], - appState: AppState, - files: BinaryFiles, - ) => void -) => () => void -``` - -Subscribes to change events, similar to [`props.onChange`](/docs/@excalidraw/excalidraw/api/props#onchange). - -Returns an unsubscribe function. - -## onPointerDown - -```tsx -( - callback: ( - activeTool: AppState["activeTool"], - pointerDownState: PointerDownState, - event: React.PointerEvent, - ) => void, -) => () => void -``` - -Subscribes to canvas `pointerdown` events. - -Returns an unsubscribe function. - -## onPointerUp - -```tsx -( - callback: ( - activeTool: AppState["activeTool"], - pointerDownState: PointerDownState, - event: PointerEvent, - ) => void, -) => () => void -``` - -Subscribes to canvas `pointerup` events. - -Returns an unsubscribe function. diff --git a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/props/initialdata.mdx b/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/props/initialdata.mdx deleted file mode 100644 index 0fec6ea..0000000 --- a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/props/initialdata.mdx +++ /dev/null @@ -1,55 +0,0 @@ -# initialData - -
-{ elements?: ExcalidrawElement[], appState?: AppState }
-
- -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/packages/excalidraw/element/types.ts#L114) | The `elements` with which `Excalidraw` should be mounted. | -| `appState` | [AppState](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/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/packages/excalidraw/types.ts#L247) | Promise<[LibraryItems](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/types.ts#L200)> | This library items with which `Excalidraw` should be mounted. | -| `files` | [BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/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/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/props/props.mdx b/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/props/props.mdx deleted file mode 100644 index 607e971..0000000 --- a/excalidraw/dev-docs/docs/@excalidraw/excalidraw/api/props/props.mdx +++ /dev/null @@ -1,261 +0,0 @@ -# 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. | -| [`excalidrawAPI`](/docs/@excalidraw/excalidraw/api/props/excalidraw-api) | `function` | \_ | Callback triggered with the excalidraw api once rendered | -| [`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 events | -| [`onScrollChange`](#onscrollchange) | `function` | \_ | This prop if passed gets triggered when scrolling the canvas. | -| [`onPaste`](#onpaste) | `function` | \_ | Callback to be triggered if passed when something is pasted into the scene | -| [`onLibraryChange`](#onlibrarychange) | `function` | \_ | The callback if supplied is triggered when the library is updated and receives the library items. | -| [`generateLinkForSelection`](#generatelinkforselection) | `function` | \_ | Allows you to override `url` generation when linking to Excalidraw elements. | -| [`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. | -| [`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/packages/excalidraw/constants.ts#L151) | To customise UI options. Currently we support customising [`canvas actions`](/docs/@excalidraw/excalidraw/api/props/ui-options#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 | -| [`validateEmbeddable`](#validateembeddable) | `string[]` \| `boolean` \| `RegExp` \| `RegExp[]` \| ((link: string) => boolean | undefined) | \_ | use for custom src url validation | -| [`renderEmbeddable`](/docs/@excalidraw/excalidraw/api/props/render-props#renderEmbeddable) | `function` | \_ | Render function that can override the built-in `