Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 332bc4d732 |
+2
-7
@@ -1,5 +1,3 @@
|
|||||||
MODE="development"
|
|
||||||
|
|
||||||
VITE_APP_BACKEND_V2_GET_URL=https://json-dev.excalidraw.com/api/v2/
|
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_BACKEND_V2_POST_URL=https://json-dev.excalidraw.com/api/v2/post/
|
||||||
|
|
||||||
@@ -12,7 +10,7 @@ VITE_APP_WS_SERVER_URL=http://localhost:3002
|
|||||||
VITE_APP_PLUS_LP=https://plus.excalidraw.com
|
VITE_APP_PLUS_LP=https://plus.excalidraw.com
|
||||||
VITE_APP_PLUS_APP=http://localhost:3000
|
VITE_APP_PLUS_APP=http://localhost:3000
|
||||||
|
|
||||||
VITE_APP_AI_BACKEND=http://localhost:3016
|
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"}'
|
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"}'
|
||||||
|
|
||||||
@@ -27,7 +25,7 @@ VITE_APP_ENABLE_TRACKING=true
|
|||||||
FAST_REFRESH=false
|
FAST_REFRESH=false
|
||||||
|
|
||||||
# The port the run the dev server
|
# The port the run the dev server
|
||||||
VITE_APP_PORT=3001
|
VITE_APP_PORT=3000
|
||||||
|
|
||||||
#Debug flags
|
#Debug flags
|
||||||
|
|
||||||
@@ -50,6 +48,3 @@ UNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD
|
|||||||
s9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot
|
s9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot
|
||||||
kdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS
|
kdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS
|
||||||
HQIDAQAB'
|
HQIDAQAB'
|
||||||
|
|
||||||
# set to true in .env.development.local to disable the prevent unload dialog
|
|
||||||
VITE_APP_DISABLE_PREVENT_UNLOAD=
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
MODE="production"
|
|
||||||
|
|
||||||
VITE_APP_BACKEND_V2_GET_URL=https://json.excalidraw.com/api/v2/
|
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_BACKEND_V2_POST_URL=https://json.excalidraw.com/api/v2/post/
|
||||||
|
|
||||||
|
|||||||
+1
-43
@@ -1,21 +1,6 @@
|
|||||||
{
|
{
|
||||||
"extends": ["@excalidraw/eslint-config", "react-app"],
|
"extends": ["@excalidraw/eslint-config", "react-app"],
|
||||||
"rules": {
|
"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",
|
"import/no-anonymous-default-export": "off",
|
||||||
"no-restricted-globals": "off",
|
"no-restricted-globals": "off",
|
||||||
"@typescript-eslint/consistent-type-imports": [
|
"@typescript-eslint/consistent-type-imports": [
|
||||||
@@ -32,33 +17,6 @@
|
|||||||
"name": "jotai",
|
"name": "jotai",
|
||||||
"message": "Do not import from \"jotai\" directly. Use our app-specific modules (\"editor-jotai\" or \"app-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
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"files": ["packages/excalidraw/**/*.{ts,tsx}"],
|
|
||||||
"excludedFiles": ["packages/excalidraw/**/*.test.{ts,tsx}", "packages/excalidraw/**/*.test.*.{ts,tsx}"],
|
|
||||||
"rules": {
|
|
||||||
"@typescript-eslint/no-restricted-imports": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"patterns": [
|
|
||||||
{
|
|
||||||
"group": ["@excalidraw/excalidraw"],
|
|
||||||
"message": "Do not import from the barrel 'index.tsx' files. Use direct relative imports to the specific module instead.",
|
|
||||||
"allowTypeImports": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"paths": [".", "..", "../..", "../../..", "../../../..", "../../../../..", "../index", "../../index", "../../../index", "../../../../index"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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}
|
|
||||||
@@ -12,10 +12,10 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js 18.x
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 18.x
|
||||||
- name: Set up publish access
|
- name: Set up publish access
|
||||||
run: |
|
run: |
|
||||||
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
|
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
|
||||||
@@ -24,4 +24,4 @@ jobs:
|
|||||||
- name: Auto release
|
- name: Auto release
|
||||||
run: |
|
run: |
|
||||||
yarn add @actions/core -W
|
yarn add @actions/core -W
|
||||||
yarn release --tag=next --non-interactive
|
yarn autorelease
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
name: Auto release excalidraw preview
|
||||||
|
on:
|
||||||
|
issue_comment:
|
||||||
|
types: [created, edited]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Auto-release-excalidraw-preview:
|
||||||
|
name: Auto release preview
|
||||||
|
if: github.event.comment.body == '@excalibot trigger release' && github.event.issue.pull_request
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: React to release comment
|
||||||
|
uses: peter-evans/create-or-update-comment@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.PUSH_TRANSLATIONS_COVERAGE_PAT }}
|
||||||
|
comment-id: ${{ github.event.comment.id }}
|
||||||
|
reactions: "+1"
|
||||||
|
- name: Get PR SHA
|
||||||
|
id: sha
|
||||||
|
uses: actions/github-script@v4
|
||||||
|
with:
|
||||||
|
result-encoding: string
|
||||||
|
script: |
|
||||||
|
const { owner, repo, number } = context.issue;
|
||||||
|
const pr = await github.pulls.get({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
pull_number: number,
|
||||||
|
});
|
||||||
|
return pr.data.head.sha
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ steps.sha.outputs.result }}
|
||||||
|
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 preview
|
||||||
|
id: "autorelease"
|
||||||
|
run: |
|
||||||
|
yarn add @actions/core -W
|
||||||
|
yarn autorelease preview ${{ github.event.issue.number }}
|
||||||
|
- name: Post comment post release
|
||||||
|
if: always()
|
||||||
|
uses: peter-evans/create-or-update-comment@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.PUSH_TRANSLATIONS_COVERAGE_PAT }}
|
||||||
|
issue-number: ${{ github.event.issue.number }}
|
||||||
|
body: "@${{ github.event.comment.user.login }} ${{ steps.autorelease.outputs.result }}"
|
||||||
@@ -9,10 +9,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js 18.x
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 18.x
|
||||||
|
|
||||||
- name: Install and lint
|
- name: Install and lint
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
token: ${{ secrets.PUSH_TRANSLATIONS_COVERAGE_PAT }}
|
token: ${{ secrets.PUSH_TRANSLATIONS_COVERAGE_PAT }}
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js 18.x
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 18.x
|
||||||
|
|
||||||
- name: Create report file
|
- name: Create report file
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -17,14 +17,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
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
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v3
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: excalidraw/excalidraw:latest
|
tags: excalidraw/excalidraw:latest
|
||||||
platforms: linux/amd64, linux/arm64, linux/arm/v7
|
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js 18.x
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 18.x
|
||||||
- name: Install and build
|
- name: Install and build
|
||||||
run: |
|
run: |
|
||||||
yarn --frozen-lockfile
|
yarn --frozen-lockfile
|
||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
export SENTRY_RELEASE=$(sentry-cli releases propose-version)
|
export SENTRY_RELEASE=$(sentry-cli releases propose-version)
|
||||||
sentry-cli releases new $SENTRY_RELEASE --project $SENTRY_PROJECT
|
sentry-cli releases new $SENTRY_RELEASE --project $SENTRY_PROJECT
|
||||||
sentry-cli releases set-commits --auto $SENTRY_RELEASE
|
sentry-cli releases set-commits --auto $SENTRY_RELEASE
|
||||||
sentry-cli sourcemaps upload --release $SENTRY_RELEASE --no-rewrite ./build/static/js/ --url-prefix "~/static/js"
|
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 finalize $SENTRY_RELEASE
|
||||||
sentry-cli releases deploys $SENTRY_RELEASE new -e production
|
sentry-cli releases deploys $SENTRY_RELEASE new -e production
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js 18.x
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 18.x
|
||||||
- name: Install in packages/excalidraw
|
- name: Install in packages/excalidraw
|
||||||
run: yarn
|
run: yarn
|
||||||
working-directory: packages/excalidraw
|
working-directory: packages/excalidraw
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ jobs:
|
|||||||
- name: "Install Node"
|
- name: "Install Node"
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: "20.x"
|
node-version: "18.x"
|
||||||
- name: "Install Deps"
|
- name: "Install Deps"
|
||||||
run: yarn install
|
run: yarn install
|
||||||
- name: "Test Coverage"
|
- name: "Test Coverage"
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js 18.x
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 18.x
|
||||||
- name: Install and test
|
- name: Install and test
|
||||||
run: |
|
run: |
|
||||||
yarn install
|
yarn install
|
||||||
|
|||||||
+1
-2
@@ -25,5 +25,4 @@ packages/excalidraw/types
|
|||||||
coverage
|
coverage
|
||||||
dev-dist
|
dev-dist
|
||||||
html
|
html
|
||||||
meta*.json
|
meta*.json
|
||||||
.claude
|
|
||||||
@@ -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
|
|
||||||
+4
-5
@@ -1,4 +1,4 @@
|
|||||||
FROM --platform=${BUILDPLATFORM} node:18 AS build
|
FROM node:18 AS build
|
||||||
|
|
||||||
WORKDIR /opt/node_app
|
WORKDIR /opt/node_app
|
||||||
|
|
||||||
@@ -6,14 +6,13 @@ COPY . .
|
|||||||
|
|
||||||
# do not ignore optional dependencies:
|
# do not ignore optional dependencies:
|
||||||
# Error: Cannot find module @rollup/rollup-linux-x64-gnu
|
# Error: Cannot find module @rollup/rollup-linux-x64-gnu
|
||||||
RUN --mount=type=cache,target=/root/.cache/yarn \
|
RUN yarn --network-timeout 600000
|
||||||
npm_config_target_arch=${TARGETARCH} yarn --network-timeout 600000
|
|
||||||
|
|
||||||
ARG NODE_ENV=production
|
ARG NODE_ENV=production
|
||||||
|
|
||||||
RUN npm_config_target_arch=${TARGETARCH} yarn build:app:docker
|
RUN yarn build:app:docker
|
||||||
|
|
||||||
FROM --platform=${TARGETPLATFORM} nginx:1.27-alpine
|
FROM nginx:1.27-alpine
|
||||||
|
|
||||||
COPY --from=build /opt/node_app/excalidraw-app/build /usr/share/nginx/html
|
COPY --from=build /opt/node_app/excalidraw-app/build /usr/share/nginx/html
|
||||||
|
|
||||||
|
|||||||
@@ -23,17 +23,20 @@
|
|||||||
<br />
|
<br />
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/excalidraw/excalidraw/blob/master/LICENSE">
|
<a href="https://github.com/excalidraw/excalidraw/blob/master/LICENSE">
|
||||||
<img alt="Excalidraw is released under the MIT license." src="https://img.shields.io/badge/license-MIT-blue.svg" /></a>
|
<img alt="Excalidraw is released under the MIT license." src="https://img.shields.io/badge/license-MIT-blue.svg" />
|
||||||
|
</a>
|
||||||
<a href="https://www.npmjs.com/package/@excalidraw/excalidraw">
|
<a href="https://www.npmjs.com/package/@excalidraw/excalidraw">
|
||||||
<img alt="npm downloads/month" src="https://img.shields.io/npm/dm/@excalidraw/excalidraw" /></a>
|
<img alt="npm downloads/month" src="https://img.shields.io/npm/dm/@excalidraw/excalidraw" />
|
||||||
|
</a>
|
||||||
<a href="https://docs.excalidraw.com/docs/introduction/contributing">
|
<a href="https://docs.excalidraw.com/docs/introduction/contributing">
|
||||||
<img alt="PRs welcome!" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" /></a>
|
<img alt="PRs welcome!" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat" />
|
||||||
|
</a>
|
||||||
<a href="https://discord.gg/UexuTaE">
|
<a href="https://discord.gg/UexuTaE">
|
||||||
<img alt="Chat on Discord" src="https://img.shields.io/discord/723672430744174682?color=738ad6&label=Chat%20on%20Discord&logo=discord&logoColor=ffffff&widge=false"/></a>
|
<img alt="Chat on Discord" src="https://img.shields.io/discord/723672430744174682?color=738ad6&label=Chat%20on%20Discord&logo=discord&logoColor=ffffff&widge=false"/>
|
||||||
<a href="https://deepwiki.com/excalidraw/excalidraw">
|
</a>
|
||||||
<img alt="Ask DeepWiki" src="https://deepwiki.com/badge.svg" /></a>
|
|
||||||
<a href="https://twitter.com/excalidraw">
|
<a href="https://twitter.com/excalidraw">
|
||||||
<img alt="Follow Excalidraw on Twitter" src="https://img.shields.io/twitter/follow/excalidraw.svg?label=follow+@excalidraw&style=social&logo=twitter"/></a>
|
<img alt="Follow Excalidraw on Twitter" src="https://img.shields.io/twitter/follow/excalidraw.svg?label=follow+@excalidraw&style=social&logo=twitter"/>
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
@@ -60,7 +63,7 @@ The Excalidraw editor (npm package) supports:
|
|||||||
- 🏗️ Customizable.
|
- 🏗️ Customizable.
|
||||||
- 📷 Image support.
|
- 📷 Image support.
|
||||||
- 😀 Shape libraries support.
|
- 😀 Shape libraries support.
|
||||||
- 🌐 Localization (i18n) support.
|
- 👅 Localization (i18n) support.
|
||||||
- 🖼️ Export to PNG, SVG & clipboard.
|
- 🖼️ Export to PNG, SVG & clipboard.
|
||||||
- 💾 Open format - export drawings as an `.excalidraw` json file.
|
- 💾 Open format - export drawings as an `.excalidraw` json file.
|
||||||
- ⚒️ Wide range of tools - rectangle, circle, diamond, arrow, line, free-draw, eraser...
|
- ⚒️ Wide range of tools - rectangle, circle, diamond, arrow, line, free-draw, eraser...
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
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.
|
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.
|
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**
|
**Usage**
|
||||||
|
|
||||||
```jsx live
|
```jsx live
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<div style={{ height: "500px" }}>
|
<div style={{ height: "500px"}}>
|
||||||
<Excalidraw>
|
<Excalidraw>
|
||||||
<Footer>
|
<Footer>
|
||||||
<button
|
<button
|
||||||
@@ -25,21 +25,21 @@ function App() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This will only work for `Desktop` devices.
|
This will only for `Desktop` devices.
|
||||||
|
|
||||||
For `mobile` you will need to render it inside the [MainMenu](#mainmenu). You can use the [`useEditorInterface`](#useEditorInterface) hook to check the type of device, this will be available only inside the `children` of `Excalidraw` component.
|
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.
|
Open the `Menu` in the below playground and you will see the `custom footer` rendered.
|
||||||
|
|
||||||
```jsx live noInline
|
```jsx live noInline
|
||||||
const MobileFooter = ({}) => {
|
const MobileFooter = ({}) => {
|
||||||
const editorInterface = useEditorInterface();
|
const device = useDevice();
|
||||||
if (editorInterface.formFactor === "phone") {
|
if (device.editor.isMobile) {
|
||||||
return (
|
return (
|
||||||
<Footer>
|
<Footer>
|
||||||
<button
|
<button
|
||||||
className="custom-footer"
|
className="custom-footer"
|
||||||
style={{ marginLeft: "20px", height: "2rem" }}
|
style= {{ marginLeft: '20px', height: '2rem'}}
|
||||||
onClick={() => alert("This is custom footer in mobile menu")}
|
onClick={() => alert("This is custom footer in mobile menu")}
|
||||||
>
|
>
|
||||||
custom footer
|
custom footer
|
||||||
@@ -65,4 +65,4 @@ const App = () => (
|
|||||||
// Need to render when code is span across multiple components
|
// Need to render when code is span across multiple components
|
||||||
// in Live Code blocks editor
|
// in Live Code blocks editor
|
||||||
render(<App />);
|
render(<App />);
|
||||||
```
|
```
|
||||||
@@ -363,7 +363,13 @@ This API has the below signature. It sets the `tool` passed in param as the acti
|
|||||||
```ts
|
```ts
|
||||||
(
|
(
|
||||||
tool: (
|
tool: (
|
||||||
| { type: ToolType }
|
| (
|
||||||
|
| { type: Exclude<ToolType, "image"> }
|
||||||
|
| {
|
||||||
|
type: Extract<ToolType, "image">;
|
||||||
|
insertOnCanvasDirectly?: boolean;
|
||||||
|
}
|
||||||
|
)
|
||||||
| { type: "custom"; customType: string }
|
| { type: "custom"; customType: string }
|
||||||
) & { locked?: boolean },
|
) & { locked?: boolean },
|
||||||
) => {};
|
) => {};
|
||||||
@@ -371,7 +377,7 @@ This API has the below signature. It sets the `tool` passed in param as the acti
|
|||||||
|
|
||||||
| Name | Type | Default | Description |
|
| 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 |
|
| `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. When setting `image` as active tool, the insertion onto canvas when using image tool is disabled by default, so you can enable it by setting `insertOnCanvasDirectly` to `true` |
|
||||||
| `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 |
|
| `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
|
## setCursor
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
All `props` are _optional_.
|
All `props` are _optional_.
|
||||||
|
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
||||||
| [`initialData`](/docs/@excalidraw/excalidraw/api/props/initialdata) | `object` | `null` | <code>Promise<object | null></code> | `null` | The initial data with which app loads. |
|
| [`initialData`](/docs/@excalidraw/excalidraw/api/props/initialdata) | `object` | `null` | <code>Promise<object | null></code> | `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 |
|
| [`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 |
|
| [`isCollaborating`](#iscollaborating) | `boolean` | \_ | This indicates if the app is in `collaboration` mode |
|
||||||
@@ -13,7 +13,7 @@ All `props` are _optional_.
|
|||||||
| [`onScrollChange`](#onscrollchange) | `function` | \_ | This prop if passed gets triggered when scrolling the canvas. |
|
| [`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 |
|
| [`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. |
|
| [`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. |
|
| [`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. |
|
| [`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 |
|
| [`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 |
|
| [`renderTopRightUI`](/docs/@excalidraw/excalidraw/api/props/render-props#rendertoprightui) | `function` | \_ | Render function that renders custom UI in top right corner |
|
||||||
@@ -29,9 +29,8 @@ All `props` are _optional_.
|
|||||||
| [`handleKeyboardGlobally`](#handlekeyboardglobally) | `boolean` | `false` | Indicates whether to bind the keyboard events to document. |
|
| [`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 |
|
| [`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 |
|
| [`generateIdForFile`](#generateidforfile) | `function` | \_ | Allows you to override `id` generation for files added on canvas |
|
||||||
| [`validateEmbeddable`](#validateembeddable) | `string[]` \| `boolean` \| `RegExp` \| `RegExp[]` \| <code>((link: string) => boolean | undefined)</code> | \_ | use for custom src url validation |
|
| [`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 `<iframe>` |
|
| [`renderEmbeddable`](/docs/@excalidraw/excalidraw/api/props/render-props#renderEmbeddable) | `function` | \_ | Render function that can override the built-in `<iframe>` |
|
||||||
| [`renderScrollbars`] | `boolean`| | `false` | Indicates whether scrollbars will be shown
|
|
||||||
|
|
||||||
### Storing custom data on Excalidraw elements
|
### Storing custom data on Excalidraw elements
|
||||||
|
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ viewportCoordsToSceneCoords({ clientX: number, clientY: number },<br/> 
|
|||||||
appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/types.ts#L95">AppState</a><br/>): {x: number, y: number}
|
appState: <a href="https://github.com/excalidraw/excalidraw/blob/master/packages/excalidraw/types.ts#L95">AppState</a><br/>): {x: number, y: number}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
### useEditorInterface
|
### 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.
|
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.
|
||||||
|
|
||||||
@@ -300,8 +300,8 @@ Open the `main menu` in the below example to view the footer.
|
|||||||
|
|
||||||
```jsx live noInline
|
```jsx live noInline
|
||||||
const MobileFooter = ({}) => {
|
const MobileFooter = ({}) => {
|
||||||
const editorInterface = useEditorInterface();
|
const device = useDevice();
|
||||||
if (editorInterface.formFactor === "phone") {
|
if (device.editor.isMobile) {
|
||||||
return (
|
return (
|
||||||
<Footer>
|
<Footer>
|
||||||
<button
|
<button
|
||||||
@@ -336,20 +336,12 @@ render(<App />);
|
|||||||
The `device` has the following `attributes`, some grouped into `viewport` and `editor` objects, per context.
|
The `device` has the following `attributes`, some grouped into `viewport` and `editor` objects, per context.
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ---- | ---- | ----------- |
|
| --- | --- | --- |
|
||||||
|
| `viewport.isMobile` | `boolean` | Set to `true` when viewport is in `mobile` breakpoint |
|
||||||
The `EditorInterface` object has the following properties:
|
| `viewport.isLandscape` | `boolean` | Set to `true` when the viewport is in `landscape` mode |
|
||||||
|
| `editor.canFitSidebar` | `boolean` | Set to `true` if there's enough space to fit the `sidebar` |
|
||||||
| Name | Type | Description |
|
| `editor.isMobile` | `boolean` | Set to `true` when editor container is in `mobile` breakpoint |
|
||||||
| --- | --- | --- | --- | --- | --- |
|
| `isTouchScreen` | `boolean` | Set to `true` for `touch` when touch event detected |
|
||||||
| `formFactor` | `'phone' | 'tablet' | 'desktop'` | Indicates the device type based on screen size |
|
|
||||||
| `desktopUIMode` | `'compact' | 'full'` | UI mode for desktop form factor |
|
|
||||||
| `userAgent.raw` | `string` | Raw user agent string |
|
|
||||||
| `userAgent.isMobileDevice` | `boolean` | True if device is mobile |
|
|
||||||
| `userAgent.platform` | `'ios' | 'android' | 'other' | 'unknown'` | Device platform |
|
|
||||||
| `isTouchScreen` | `boolean` | True if touch events are detected |
|
|
||||||
| `canFitSidebar` | `boolean` | True if sidebar can fit in the viewport |
|
|
||||||
| `isLandscape` | `boolean` | True if viewport is in landscape mode |
|
|
||||||
|
|
||||||
### i18n
|
### i18n
|
||||||
|
|
||||||
|
|||||||
@@ -24,16 +24,36 @@ To start the example app using the `@excalidraw/excalidraw` package, follow the
|
|||||||
|
|
||||||
[http://localhost:3001](http://localhost:3001) will open in your default browser.
|
[http://localhost:3001](http://localhost:3001) will open in your default browser.
|
||||||
|
|
||||||
This is the same example as the [CodeSandbox](https://codesandbox.io/p/sandbox/github/excalidraw/excalidraw/tree/master/examples/with-script-in-browser) example.
|
This is the same example as the [CodeSandbox](https://codesandbox.io/p/sandbox/github/excalidraw/excalidraw/tree/mrazator/release-v18/examples/with-script-in-browser) example.
|
||||||
|
|
||||||
## Releasing
|
## 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
|
### Creating a production release
|
||||||
|
|
||||||
To release the next stable version follow the below steps:
|
To release the next stable version follow the below steps:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn release --tag=latest --version=0.19.0
|
yarn prerelease:excalidraw
|
||||||
```
|
```
|
||||||
|
|
||||||
You will need to pass the `latest` tag with `version` for which you want to create the release. This will make the changes needed before publishing the packages into NPM, like updating dependencies of all `@excalidraw/*` packages, generating new entries in `CHANGELOG.md` and more.
|
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:excalidraw
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|||||||
@@ -52,4 +52,4 @@ Excalidraw takes _100%_ of `width` and `height` of the containing block so make
|
|||||||
|
|
||||||
## Demo
|
## Demo
|
||||||
|
|
||||||
Go to [CodeSandbox](https://codesandbox.io/p/sandbox/github/excalidraw/excalidraw/tree/master/examples/with-script-in-browser) example.
|
Go to [CodeSandbox](https://codesandbox.io/p/sandbox/github/excalidraw/excalidraw/tree/mrazator/release-v18/examples/with-script-in-browser) example.
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ If you want to only import `Excalidraw` component you can do :point_down:
|
|||||||
|
|
||||||
```jsx showLineNumbers
|
```jsx showLineNumbers
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
import "@excalidraw/excalidraw/index.css";
|
|
||||||
|
|
||||||
const Excalidraw = dynamic(
|
const Excalidraw = dynamic(
|
||||||
async () => (await import("@excalidraw/excalidraw")).Excalidraw,
|
async () => (await import("@excalidraw/excalidraw")).Excalidraw,
|
||||||
{
|
{
|
||||||
@@ -133,7 +131,7 @@ If you are using `pages router` then importing the wrapper dynamically would wor
|
|||||||
{/* Link should be updated to point to the latest! */}
|
{/* Link should be updated to point to the latest! */}
|
||||||
Here is a [source code](https://github.com/excalidraw/excalidraw/tree/master/examples/with-nextjs) for the example with app and pages router. You you can try it out [here](https://excalidraw-package-example-with-nextjs.vercel.app/).
|
Here is a [source code](https://github.com/excalidraw/excalidraw/tree/master/examples/with-nextjs) for the example with app and pages router. You you can try it out [here](https://excalidraw-package-example-with-nextjs.vercel.app/).
|
||||||
|
|
||||||
The `types` are available at `@excalidraw/excalidraw/types`, check [CodeSandbox](https://codesandbox.io/p/sandbox/github/excalidraw/excalidraw/tree/master/examples/with-script-in-browser) example for details.
|
The `types` are available at `@excalidraw/excalidraw/types`, check [CodeSandbox](https://codesandbox.io/p/sandbox/github/excalidraw/excalidraw/tree/mrazator/release-v18/examples/with-script-in-browser) example for details.
|
||||||
|
|
||||||
### Preact
|
### Preact
|
||||||
|
|
||||||
@@ -208,7 +206,7 @@ import TabItem from "@theme/TabItem";
|
|||||||
|
|
||||||
```js showLineNumbers
|
```js showLineNumbers
|
||||||
// See https://www.npmjs.com/package/@excalidraw/excalidraw documentation.
|
// See https://www.npmjs.com/package/@excalidraw/excalidraw documentation.
|
||||||
import * as ExcalidrawLib from 'https://esm.sh/@excalidraw/excalidraw@0.18.0/dist/dev/index.js?external=react,react-dom';
|
import * as ExcalidrawLib from 'https://esm.sh/@excalidraw/excalidraw@0.18.0-rc.1/dist/dev/index.js?external=react,react-dom';
|
||||||
import React from "https://esm.sh/react@19.0.0";
|
import React from "https://esm.sh/react@19.0.0";
|
||||||
import ReactDOM from "https://esm.sh/react-dom@19.0.0"
|
import ReactDOM from "https://esm.sh/react-dom@19.0.0"
|
||||||
|
|
||||||
@@ -237,4 +235,4 @@ root.render(React.createElement(App));
|
|||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
You can try it out [here](https://jsfiddle.net/vfn6dm14/3/).
|
You can try it out [here](https://jsfiddle.net/64y130L8/1/).
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
"@docusaurus/core": "2.2.0",
|
"@docusaurus/core": "2.2.0",
|
||||||
"@docusaurus/preset-classic": "2.2.0",
|
"@docusaurus/preset-classic": "2.2.0",
|
||||||
"@docusaurus/theme-live-codeblock": "2.2.0",
|
"@docusaurus/theme-live-codeblock": "2.2.0",
|
||||||
"@excalidraw/excalidraw": "0.18.0",
|
"@excalidraw/excalidraw": "0.18.0-rc.5",
|
||||||
"@mdx-js/react": "^1.6.22",
|
"@mdx-js/react": "^1.6.22",
|
||||||
"clsx": "^1.2.1",
|
"clsx": "^1.2.1",
|
||||||
"docusaurus-plugin-sass": "0.2.3",
|
"docusaurus-plugin-sass": "0.2.3",
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import clsx from "clsx";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import clsx from "clsx";
|
||||||
import styles from "./styles.module.css";
|
import styles from "./styles.module.css";
|
||||||
|
|
||||||
const FeatureList = [
|
const FeatureList = [
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import clsx from "clsx";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import clsx from "clsx";
|
||||||
import styles from "./styles.module.css";
|
import styles from "./styles.module.css";
|
||||||
|
|
||||||
type FeatureItem = {
|
type FeatureItem = {
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
|
import React from "react";
|
||||||
|
import clsx from "clsx";
|
||||||
|
import Layout from "@theme/Layout";
|
||||||
import Link from "@docusaurus/Link";
|
import Link from "@docusaurus/Link";
|
||||||
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
||||||
import HomepageFeatures from "@site/src/components/Homepage";
|
|
||||||
import Layout from "@theme/Layout";
|
|
||||||
import clsx from "clsx";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
import HomepageFeatures from "@site/src/components/Homepage";
|
||||||
|
|
||||||
function HomepageHeader() {
|
function HomepageHeader() {
|
||||||
const { siteConfig } = useDocusaurusContext();
|
const { siteConfig } = useDocusaurusContext();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Import the original mapper
|
// Import the original mapper
|
||||||
import Highlight from "@site/src/components/Highlight";
|
|
||||||
import MDXComponents from "@theme-original/MDXComponents";
|
import MDXComponents from "@theme-original/MDXComponents";
|
||||||
|
import Highlight from "@site/src/components/Highlight";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
// Re-use the default mapping
|
// Re-use the default mapping
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ if (ExecutionEnvironment.canUseDOM) {
|
|||||||
const Excalidraw = React.forwardRef((props, ref) => {
|
const Excalidraw = React.forwardRef((props, ref) => {
|
||||||
if (!window.EXCALIDRAW_ASSET_PATH) {
|
if (!window.EXCALIDRAW_ASSET_PATH) {
|
||||||
window.EXCALIDRAW_ASSET_PATH =
|
window.EXCALIDRAW_ASSET_PATH =
|
||||||
"https://esm.sh/@excalidraw/excalidraw@0.18.0/dist/prod/";
|
"https://esm.sh/@excalidraw/excalidraw@0.18.0-rc.5/dist/prod/";
|
||||||
}
|
}
|
||||||
|
|
||||||
const { colorMode } = useColorMode();
|
const { colorMode } = useColorMode();
|
||||||
@@ -33,7 +33,6 @@ const ExcalidrawScope = {
|
|||||||
initialData,
|
initialData,
|
||||||
useI18n: ExcalidrawComp.useI18n,
|
useI18n: ExcalidrawComp.useI18n,
|
||||||
convertToExcalidrawElements: ExcalidrawComp.convertToExcalidrawElements,
|
convertToExcalidrawElements: ExcalidrawComp.convertToExcalidrawElements,
|
||||||
CaptureUpdateAction: ExcalidrawComp.CaptureUpdateAction,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ExcalidrawScope;
|
export default ExcalidrawScope;
|
||||||
|
|||||||
+130
-186
@@ -1735,16 +1735,16 @@
|
|||||||
url-loader "^4.1.1"
|
url-loader "^4.1.1"
|
||||||
webpack "^5.73.0"
|
webpack "^5.73.0"
|
||||||
|
|
||||||
"@excalidraw/excalidraw@0.18.0":
|
"@excalidraw/excalidraw@0.18.0-rc.5":
|
||||||
version "0.18.0"
|
version "0.18.0-rc.5"
|
||||||
resolved "https://registry.yarnpkg.com/@excalidraw/excalidraw/-/excalidraw-0.18.0.tgz#9f818e2df80a8735af54f8cc21da67997785532f"
|
resolved "https://registry.yarnpkg.com/@excalidraw/excalidraw/-/excalidraw-0.18.0-rc.5.tgz#c55598e01808693702251322e59bf9dba931b6e0"
|
||||||
integrity sha512-QkIiS+5qdy8lmDWTKsuy0sK/fen/LRDtbhm2lc2xcFcqhv2/zdg95bYnl+wnwwXGHo7kEmP65BSiMHE7PJ3Zpw==
|
integrity sha512-f6Z6cWlx+FWl1nxCu5F6OdKm9ooV/FPjndjIfFhGLVyERKATXhuNwZUHWwqsEW+SIGmiPG2515NG9KIOhjGd5g==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@braintree/sanitize-url" "6.0.2"
|
"@braintree/sanitize-url" "6.0.2"
|
||||||
"@excalidraw/laser-pointer" "1.3.1"
|
"@excalidraw/laser-pointer" "1.3.1"
|
||||||
"@excalidraw/mermaid-to-excalidraw" "1.1.2"
|
"@excalidraw/mermaid-to-excalidraw" "1.1.2"
|
||||||
"@excalidraw/random-username" "1.1.0"
|
"@excalidraw/random-username" "1.1.0"
|
||||||
"@radix-ui/react-popover" "1.1.6"
|
"@radix-ui/react-popover" "1.0.3"
|
||||||
"@radix-ui/react-tabs" "1.0.2"
|
"@radix-ui/react-tabs" "1.0.2"
|
||||||
browser-fs-access "0.29.1"
|
browser-fs-access "0.29.1"
|
||||||
canvas-roundrect-polyfill "0.0.1"
|
canvas-roundrect-polyfill "0.0.1"
|
||||||
@@ -1796,32 +1796,25 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@excalidraw/random-username/-/random-username-1.1.0.tgz#6f388d6a9708cf655b8c9c6aa3fa569ee71ecf0f"
|
resolved "https://registry.yarnpkg.com/@excalidraw/random-username/-/random-username-1.1.0.tgz#6f388d6a9708cf655b8c9c6aa3fa569ee71ecf0f"
|
||||||
integrity sha512-nULYsQxkWHnbmHvcs+efMkJ4/9TtvNyFeLyHdeGxW0zHs6P+jYVqcRff9A6Vq9w9JXeDRnRh2VKvTtS19GW2qA==
|
integrity sha512-nULYsQxkWHnbmHvcs+efMkJ4/9TtvNyFeLyHdeGxW0zHs6P+jYVqcRff9A6Vq9w9JXeDRnRh2VKvTtS19GW2qA==
|
||||||
|
|
||||||
"@floating-ui/core@^1.6.0":
|
"@floating-ui/core@^0.7.3":
|
||||||
version "1.6.9"
|
version "0.7.3"
|
||||||
resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.6.9.tgz#64d1da251433019dafa091de9b2886ff35ec14e6"
|
resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-0.7.3.tgz#d274116678ffae87f6b60e90f88cc4083eefab86"
|
||||||
integrity sha512-uMXCuQ3BItDUbAMhIXw7UPXRfAlOAvZzdK9BWpE60MCn+Svt3aLn9jsPTi/WNGlRUu2uI0v5S7JiIUsbsvh3fw==
|
integrity sha512-buc8BXHmG9l82+OQXOFU3Kr2XQx9ys01U/Q9HMIrZ300iLc8HLMgh7dcCqgYzAzf4BkoQvDcXf5Y+CuEZ5JBYg==
|
||||||
dependencies:
|
|
||||||
"@floating-ui/utils" "^0.2.9"
|
|
||||||
|
|
||||||
"@floating-ui/dom@^1.0.0":
|
"@floating-ui/dom@^0.5.3":
|
||||||
version "1.6.13"
|
version "0.5.4"
|
||||||
resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-1.6.13.tgz#a8a938532aea27a95121ec16e667a7cbe8c59e34"
|
resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-0.5.4.tgz#4eae73f78bcd4bd553ae2ade30e6f1f9c73fe3f1"
|
||||||
integrity sha512-umqzocjDgNRGTuO7Q8CU32dkHkECqI8ZdMZ5Swb6QAM0t5rnlrN3lGo1hdpscRd3WS8T6DKYK4ephgIH9iRh3w==
|
integrity sha512-419BMceRLq0RrmTSDxn8hf9R3VCJv2K9PUfugh5JyEFmdjzDo+e8U5EdR8nzKq8Yj1htzLm3b6eQEEam3/rrtg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@floating-ui/core" "^1.6.0"
|
"@floating-ui/core" "^0.7.3"
|
||||||
"@floating-ui/utils" "^0.2.9"
|
|
||||||
|
|
||||||
"@floating-ui/react-dom@^2.0.0":
|
"@floating-ui/react-dom@0.7.2":
|
||||||
version "2.1.2"
|
version "0.7.2"
|
||||||
resolved "https://registry.yarnpkg.com/@floating-ui/react-dom/-/react-dom-2.1.2.tgz#a1349bbf6a0e5cb5ded55d023766f20a4d439a31"
|
resolved "https://registry.yarnpkg.com/@floating-ui/react-dom/-/react-dom-0.7.2.tgz#0bf4ceccb777a140fc535c87eb5d6241c8e89864"
|
||||||
integrity sha512-06okr5cgPzMNBy+Ycse2A6udMi4bqwW/zgBF/rwjcNqWkyr82Mcg8b0vjX8OJpZFy/FKjJmw6wV7t44kK6kW7A==
|
integrity sha512-1T0sJcpHgX/u4I1OzIEhlcrvkUN8ln39nz7fMoE/2HDHrPiMFoOGR7++GYyfUmIQHkkrTinaeQsO3XWubjSvGg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@floating-ui/dom" "^1.0.0"
|
"@floating-ui/dom" "^0.5.3"
|
||||||
|
use-isomorphic-layout-effect "^1.1.1"
|
||||||
"@floating-ui/utils@^0.2.9":
|
|
||||||
version "0.2.9"
|
|
||||||
resolved "https://registry.yarnpkg.com/@floating-ui/utils/-/utils-0.2.9.tgz#50dea3616bc8191fb8e112283b49eaff03e78429"
|
|
||||||
integrity sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg==
|
|
||||||
|
|
||||||
"@hapi/hoek@^9.0.0":
|
"@hapi/hoek@^9.0.0":
|
||||||
version "9.3.0"
|
version "9.3.0"
|
||||||
@@ -1989,17 +1982,13 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "^7.13.10"
|
"@babel/runtime" "^7.13.10"
|
||||||
|
|
||||||
"@radix-ui/primitive@1.1.1":
|
"@radix-ui/react-arrow@1.0.1":
|
||||||
version "1.1.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/primitive/-/primitive-1.1.1.tgz#fc169732d755c7fbad33ba8d0cd7fd10c90dc8e3"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-arrow/-/react-arrow-1.0.1.tgz#5246adf79e97f89e819af68da51ddcf349ecf1c4"
|
||||||
integrity sha512-SJ31y+Q/zAyShtXJc8x83i9TYdbAfHZ++tUZnvjJJqFjzsdUnKsxPL6IEtBlxKkU7yzer//GQtZSV4GbldL3YA==
|
integrity sha512-1yientwXqXcErDHEv8av9ZVNEBldH8L9scVR3is20lL+jOCfcJyMFZFEY5cgIrgexsq1qggSXqiEL/d/4f+QXA==
|
||||||
|
|
||||||
"@radix-ui/react-arrow@1.1.2":
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-arrow/-/react-arrow-1.1.2.tgz#30c0d574d7bb10eed55cd7007b92d38b03c6b2ab"
|
|
||||||
integrity sha512-G+KcpzXHq24iH0uGG/pF8LyzpFJYGD4RfLjCIBfGdSLXvjLHST31RUiRVrupIBMvIppMgSzQ6l66iAxl03tdlg==
|
|
||||||
dependencies:
|
dependencies:
|
||||||
"@radix-ui/react-primitive" "2.0.2"
|
"@babel/runtime" "^7.13.10"
|
||||||
|
"@radix-ui/react-primitive" "1.0.1"
|
||||||
|
|
||||||
"@radix-ui/react-collection@1.0.1":
|
"@radix-ui/react-collection@1.0.1":
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
@@ -2019,11 +2008,6 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "^7.13.10"
|
"@babel/runtime" "^7.13.10"
|
||||||
|
|
||||||
"@radix-ui/react-compose-refs@1.1.1":
|
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-compose-refs/-/react-compose-refs-1.1.1.tgz#6f766faa975f8738269ebb8a23bad4f5a8d2faec"
|
|
||||||
integrity sha512-Y9VzoRDSJtgFMUCoiZBDVo084VQ5hfpXxVE+NgkdNsjiDBByiImMZKKhxMwCbdHvhlENG6a833CbFkOQvTricw==
|
|
||||||
|
|
||||||
"@radix-ui/react-context@1.0.0":
|
"@radix-ui/react-context@1.0.0":
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-context/-/react-context-1.0.0.tgz#f38e30c5859a9fb5e9aa9a9da452ee3ed9e0aee0"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-context/-/react-context-1.0.0.tgz#f38e30c5859a9fb5e9aa9a9da452ee3ed9e0aee0"
|
||||||
@@ -2031,11 +2015,6 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "^7.13.10"
|
"@babel/runtime" "^7.13.10"
|
||||||
|
|
||||||
"@radix-ui/react-context@1.1.1":
|
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-context/-/react-context-1.1.1.tgz#82074aa83a472353bb22e86f11bcbd1c61c4c71a"
|
|
||||||
integrity sha512-UASk9zi+crv9WteK/NU4PLvOoL3OuE6BWVKNF6hPRBtYBDXQ2u5iu3O59zUlJiTVvkyuycnqrztsHVJwcK9K+Q==
|
|
||||||
|
|
||||||
"@radix-ui/react-direction@1.0.0":
|
"@radix-ui/react-direction@1.0.0":
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-direction/-/react-direction-1.0.0.tgz#a2e0b552352459ecf96342c79949dd833c1e6e45"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-direction/-/react-direction-1.0.0.tgz#a2e0b552352459ecf96342c79949dd833c1e6e45"
|
||||||
@@ -2043,30 +2022,34 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "^7.13.10"
|
"@babel/runtime" "^7.13.10"
|
||||||
|
|
||||||
"@radix-ui/react-dismissable-layer@1.1.5":
|
"@radix-ui/react-dismissable-layer@1.0.2":
|
||||||
version "1.1.5"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-dismissable-layer/-/react-dismissable-layer-1.1.5.tgz#96dde2be078c694a621e55e047406c58cd5fe774"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-dismissable-layer/-/react-dismissable-layer-1.0.2.tgz#f04d1061bddf00b1ca304148516b9ddc62e45fb2"
|
||||||
integrity sha512-E4TywXY6UsXNRhFrECa5HAvE5/4BFcGyfTyK36gP+pAW1ed7UTK4vKwdr53gAJYwqbfCWC6ATvJa3J3R/9+Qrg==
|
integrity sha512-WjJzMrTWROozDqLB0uRWYvj4UuXsM/2L19EmQ3Au+IJWqwvwq9Bwd+P8ivo0Deg9JDPArR1I6MbWNi1CmXsskg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@radix-ui/primitive" "1.1.1"
|
"@babel/runtime" "^7.13.10"
|
||||||
"@radix-ui/react-compose-refs" "1.1.1"
|
"@radix-ui/primitive" "1.0.0"
|
||||||
"@radix-ui/react-primitive" "2.0.2"
|
"@radix-ui/react-compose-refs" "1.0.0"
|
||||||
"@radix-ui/react-use-callback-ref" "1.1.0"
|
"@radix-ui/react-primitive" "1.0.1"
|
||||||
"@radix-ui/react-use-escape-keydown" "1.1.0"
|
"@radix-ui/react-use-callback-ref" "1.0.0"
|
||||||
|
"@radix-ui/react-use-escape-keydown" "1.0.2"
|
||||||
|
|
||||||
"@radix-ui/react-focus-guards@1.1.1":
|
"@radix-ui/react-focus-guards@1.0.0":
|
||||||
version "1.1.1"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-focus-guards/-/react-focus-guards-1.1.1.tgz#8635edd346304f8b42cae86b05912b61aef27afe"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-focus-guards/-/react-focus-guards-1.0.0.tgz#339c1c69c41628c1a5e655f15f7020bf11aa01fa"
|
||||||
integrity sha512-pSIwfrT1a6sIoDASCSpFwOasEwKTZWDw/iBdtnqKO7v6FeOzYJ7U53cPzYFVR3geGGXgVHaH+CdngrrAzqUGxg==
|
integrity sha512-UagjDk4ijOAnGu4WMUPj9ahi7/zJJqNZ9ZAiGPp7waUWJO0O1aWXi/udPphI0IUjvrhBsZJGSN66dR2dsueLWQ==
|
||||||
|
|
||||||
"@radix-ui/react-focus-scope@1.1.2":
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-focus-scope/-/react-focus-scope-1.1.2.tgz#c0a4519cd95c772606a82fc5b96226cd7fdd2602"
|
|
||||||
integrity sha512-zxwE80FCU7lcXUGWkdt6XpTTCKPitG1XKOwViTxHVKIJhZl9MvIl2dVHeZENCWD9+EdWv05wlaEkRXUykU27RA==
|
|
||||||
dependencies:
|
dependencies:
|
||||||
"@radix-ui/react-compose-refs" "1.1.1"
|
"@babel/runtime" "^7.13.10"
|
||||||
"@radix-ui/react-primitive" "2.0.2"
|
|
||||||
"@radix-ui/react-use-callback-ref" "1.1.0"
|
"@radix-ui/react-focus-scope@1.0.1":
|
||||||
|
version "1.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-focus-scope/-/react-focus-scope-1.0.1.tgz#faea8c25f537c5a5c38c50914b63722db0e7f951"
|
||||||
|
integrity sha512-Ej2MQTit8IWJiS2uuujGUmxXjF/y5xZptIIQnyd2JHLwtV0R2j9NRVoRj/1j/gJ7e3REdaBw4Hjf4a1ImhkZcQ==
|
||||||
|
dependencies:
|
||||||
|
"@babel/runtime" "^7.13.10"
|
||||||
|
"@radix-ui/react-compose-refs" "1.0.0"
|
||||||
|
"@radix-ui/react-primitive" "1.0.1"
|
||||||
|
"@radix-ui/react-use-callback-ref" "1.0.0"
|
||||||
|
|
||||||
"@radix-ui/react-id@1.0.0":
|
"@radix-ui/react-id@1.0.0":
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
@@ -2076,57 +2059,52 @@
|
|||||||
"@babel/runtime" "^7.13.10"
|
"@babel/runtime" "^7.13.10"
|
||||||
"@radix-ui/react-use-layout-effect" "1.0.0"
|
"@radix-ui/react-use-layout-effect" "1.0.0"
|
||||||
|
|
||||||
"@radix-ui/react-id@1.1.0":
|
"@radix-ui/react-popover@1.0.3":
|
||||||
|
version "1.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-popover/-/react-popover-1.0.3.tgz#65ae2ee1fca2d7fd750308549eb8e0857c6160fe"
|
||||||
|
integrity sha512-YwedSukfWsyJs3/yP3yXUq44k4/JBe3jqU63Z8v2i19qZZ3dsx32oma17ztgclWPNuqp3A+Xa9UiDlZHyVX8Vg==
|
||||||
|
dependencies:
|
||||||
|
"@babel/runtime" "^7.13.10"
|
||||||
|
"@radix-ui/primitive" "1.0.0"
|
||||||
|
"@radix-ui/react-compose-refs" "1.0.0"
|
||||||
|
"@radix-ui/react-context" "1.0.0"
|
||||||
|
"@radix-ui/react-dismissable-layer" "1.0.2"
|
||||||
|
"@radix-ui/react-focus-guards" "1.0.0"
|
||||||
|
"@radix-ui/react-focus-scope" "1.0.1"
|
||||||
|
"@radix-ui/react-id" "1.0.0"
|
||||||
|
"@radix-ui/react-popper" "1.1.0"
|
||||||
|
"@radix-ui/react-portal" "1.0.1"
|
||||||
|
"@radix-ui/react-presence" "1.0.0"
|
||||||
|
"@radix-ui/react-primitive" "1.0.1"
|
||||||
|
"@radix-ui/react-slot" "1.0.1"
|
||||||
|
"@radix-ui/react-use-controllable-state" "1.0.0"
|
||||||
|
aria-hidden "^1.1.1"
|
||||||
|
react-remove-scroll "2.5.5"
|
||||||
|
|
||||||
|
"@radix-ui/react-popper@1.1.0":
|
||||||
version "1.1.0"
|
version "1.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-id/-/react-id-1.1.0.tgz#de47339656594ad722eb87f94a6b25f9cffae0ed"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-popper/-/react-popper-1.1.0.tgz#2be7e4c0cd4581f54277ca33a981c9037d2a8e60"
|
||||||
integrity sha512-EJUrI8yYh7WOjNOqpoJaf1jlFIH2LvtgAl+YcFqNCa+4hj64ZXmPkAKOFs/ukjz3byN6bdb/AVUqHkI8/uWWMA==
|
integrity sha512-07U7jpI0dZcLRAxT7L9qs6HecSoPhDSJybF7mEGHJDBDv+ZoGCvIlva0s+WxMXwJEav+ckX3hAlXBtnHmuvlCQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@radix-ui/react-use-layout-effect" "1.1.0"
|
"@babel/runtime" "^7.13.10"
|
||||||
|
"@floating-ui/react-dom" "0.7.2"
|
||||||
|
"@radix-ui/react-arrow" "1.0.1"
|
||||||
|
"@radix-ui/react-compose-refs" "1.0.0"
|
||||||
|
"@radix-ui/react-context" "1.0.0"
|
||||||
|
"@radix-ui/react-primitive" "1.0.1"
|
||||||
|
"@radix-ui/react-use-callback-ref" "1.0.0"
|
||||||
|
"@radix-ui/react-use-layout-effect" "1.0.0"
|
||||||
|
"@radix-ui/react-use-rect" "1.0.0"
|
||||||
|
"@radix-ui/react-use-size" "1.0.0"
|
||||||
|
"@radix-ui/rect" "1.0.0"
|
||||||
|
|
||||||
"@radix-ui/react-popover@1.1.6":
|
"@radix-ui/react-portal@1.0.1":
|
||||||
version "1.1.6"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-popover/-/react-popover-1.1.6.tgz#699634dbc7899429f657bb590d71fb3ca0904087"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-portal/-/react-portal-1.0.1.tgz#169c5a50719c2bb0079cf4c91a27aa6d37e5dd33"
|
||||||
integrity sha512-NQouW0x4/GnkFJ/pRqsIS3rM/k97VzKnVb2jB7Gq7VEGPy5g7uNV1ykySFt7eWSp3i2uSGFwaJcvIRJBAHmmFg==
|
integrity sha512-NY2vUWI5WENgAT1nfC6JS7RU5xRYBfjZVLq0HmgEN1Ezy3rk/UruMV4+Rd0F40PEaFC5SrLS1ixYvcYIQrb4Ig==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@radix-ui/primitive" "1.1.1"
|
"@babel/runtime" "^7.13.10"
|
||||||
"@radix-ui/react-compose-refs" "1.1.1"
|
"@radix-ui/react-primitive" "1.0.1"
|
||||||
"@radix-ui/react-context" "1.1.1"
|
|
||||||
"@radix-ui/react-dismissable-layer" "1.1.5"
|
|
||||||
"@radix-ui/react-focus-guards" "1.1.1"
|
|
||||||
"@radix-ui/react-focus-scope" "1.1.2"
|
|
||||||
"@radix-ui/react-id" "1.1.0"
|
|
||||||
"@radix-ui/react-popper" "1.2.2"
|
|
||||||
"@radix-ui/react-portal" "1.1.4"
|
|
||||||
"@radix-ui/react-presence" "1.1.2"
|
|
||||||
"@radix-ui/react-primitive" "2.0.2"
|
|
||||||
"@radix-ui/react-slot" "1.1.2"
|
|
||||||
"@radix-ui/react-use-controllable-state" "1.1.0"
|
|
||||||
aria-hidden "^1.2.4"
|
|
||||||
react-remove-scroll "^2.6.3"
|
|
||||||
|
|
||||||
"@radix-ui/react-popper@1.2.2":
|
|
||||||
version "1.2.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-popper/-/react-popper-1.2.2.tgz#d2e1ee5a9b24419c5936a1b7f6f472b7b412b029"
|
|
||||||
integrity sha512-Rvqc3nOpwseCyj/rgjlJDYAgyfw7OC1tTkKn2ivhaMGcYt8FSBlahHOZak2i3QwkRXUXgGgzeEe2RuqeEHuHgA==
|
|
||||||
dependencies:
|
|
||||||
"@floating-ui/react-dom" "^2.0.0"
|
|
||||||
"@radix-ui/react-arrow" "1.1.2"
|
|
||||||
"@radix-ui/react-compose-refs" "1.1.1"
|
|
||||||
"@radix-ui/react-context" "1.1.1"
|
|
||||||
"@radix-ui/react-primitive" "2.0.2"
|
|
||||||
"@radix-ui/react-use-callback-ref" "1.1.0"
|
|
||||||
"@radix-ui/react-use-layout-effect" "1.1.0"
|
|
||||||
"@radix-ui/react-use-rect" "1.1.0"
|
|
||||||
"@radix-ui/react-use-size" "1.1.0"
|
|
||||||
"@radix-ui/rect" "1.1.0"
|
|
||||||
|
|
||||||
"@radix-ui/react-portal@1.1.4":
|
|
||||||
version "1.1.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-portal/-/react-portal-1.1.4.tgz#ff5401ff63c8a825c46eea96d3aef66074b8c0c8"
|
|
||||||
integrity sha512-sn2O9k1rPFYVyKd5LAJfo96JlSGVFpa1fS6UuBJfrZadudiw5tAmru+n1x7aMRQ84qDM71Zh1+SzK5QwU0tJfA==
|
|
||||||
dependencies:
|
|
||||||
"@radix-ui/react-primitive" "2.0.2"
|
|
||||||
"@radix-ui/react-use-layout-effect" "1.1.0"
|
|
||||||
|
|
||||||
"@radix-ui/react-presence@1.0.0":
|
"@radix-ui/react-presence@1.0.0":
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
@@ -2137,14 +2115,6 @@
|
|||||||
"@radix-ui/react-compose-refs" "1.0.0"
|
"@radix-ui/react-compose-refs" "1.0.0"
|
||||||
"@radix-ui/react-use-layout-effect" "1.0.0"
|
"@radix-ui/react-use-layout-effect" "1.0.0"
|
||||||
|
|
||||||
"@radix-ui/react-presence@1.1.2":
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-presence/-/react-presence-1.1.2.tgz#bb764ed8a9118b7ec4512da5ece306ded8703cdc"
|
|
||||||
integrity sha512-18TFr80t5EVgL9x1SwF/YGtfG+l0BS0PRAlCWBDoBEiDQjeKgnNZRVJp/oVBl24sr3Gbfwc/Qpj4OcWTQMsAEg==
|
|
||||||
dependencies:
|
|
||||||
"@radix-ui/react-compose-refs" "1.1.1"
|
|
||||||
"@radix-ui/react-use-layout-effect" "1.1.0"
|
|
||||||
|
|
||||||
"@radix-ui/react-primitive@1.0.1":
|
"@radix-ui/react-primitive@1.0.1":
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-primitive/-/react-primitive-1.0.1.tgz#c1ebcce283dd2f02e4fbefdaa49d1cb13dbc990a"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-primitive/-/react-primitive-1.0.1.tgz#c1ebcce283dd2f02e4fbefdaa49d1cb13dbc990a"
|
||||||
@@ -2153,13 +2123,6 @@
|
|||||||
"@babel/runtime" "^7.13.10"
|
"@babel/runtime" "^7.13.10"
|
||||||
"@radix-ui/react-slot" "1.0.1"
|
"@radix-ui/react-slot" "1.0.1"
|
||||||
|
|
||||||
"@radix-ui/react-primitive@2.0.2":
|
|
||||||
version "2.0.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-primitive/-/react-primitive-2.0.2.tgz#ac8b7854d87b0d7af388d058268d9a7eb64ca8ef"
|
|
||||||
integrity sha512-Ec/0d38EIuvDF+GZjcMU/Ze6MxntVJYO/fRlCPhCaVUyPY9WTalHJw54tp9sXeJo3tlShWpy41vQRgLRGOuz+w==
|
|
||||||
dependencies:
|
|
||||||
"@radix-ui/react-slot" "1.1.2"
|
|
||||||
|
|
||||||
"@radix-ui/react-roving-focus@1.0.2":
|
"@radix-ui/react-roving-focus@1.0.2":
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-roving-focus/-/react-roving-focus-1.0.2.tgz#d8ac2e3b8006697bdfc2b0eb06bef7e15b6245de"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-roving-focus/-/react-roving-focus-1.0.2.tgz#d8ac2e3b8006697bdfc2b0eb06bef7e15b6245de"
|
||||||
@@ -2184,13 +2147,6 @@
|
|||||||
"@babel/runtime" "^7.13.10"
|
"@babel/runtime" "^7.13.10"
|
||||||
"@radix-ui/react-compose-refs" "1.0.0"
|
"@radix-ui/react-compose-refs" "1.0.0"
|
||||||
|
|
||||||
"@radix-ui/react-slot@1.1.2":
|
|
||||||
version "1.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-slot/-/react-slot-1.1.2.tgz#daffff7b2bfe99ade63b5168407680b93c00e1c6"
|
|
||||||
integrity sha512-YAKxaiGsSQJ38VzKH86/BPRC4rh+b1Jpa+JneA5LRE7skmLPNAyeG8kPJj/oo4STLvlrs8vkf/iYyc3A5stYCQ==
|
|
||||||
dependencies:
|
|
||||||
"@radix-ui/react-compose-refs" "1.1.1"
|
|
||||||
|
|
||||||
"@radix-ui/react-tabs@1.0.2":
|
"@radix-ui/react-tabs@1.0.2":
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-tabs/-/react-tabs-1.0.2.tgz#8f5ec73ca41b151a413bdd6e00553408ff34ce07"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-tabs/-/react-tabs-1.0.2.tgz#8f5ec73ca41b151a413bdd6e00553408ff34ce07"
|
||||||
@@ -2213,11 +2169,6 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "^7.13.10"
|
"@babel/runtime" "^7.13.10"
|
||||||
|
|
||||||
"@radix-ui/react-use-callback-ref@1.1.0":
|
|
||||||
version "1.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.1.0.tgz#bce938ca413675bc937944b0d01ef6f4a6dc5bf1"
|
|
||||||
integrity sha512-CasTfvsy+frcFkbXtSJ2Zu9JHpN8TYKxkgJGWbjiZhFivxaeW7rMeZt7QELGVLaYVfFMsKHjb7Ak0nMEe+2Vfw==
|
|
||||||
|
|
||||||
"@radix-ui/react-use-controllable-state@1.0.0":
|
"@radix-ui/react-use-controllable-state@1.0.0":
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-controllable-state/-/react-use-controllable-state-1.0.0.tgz#a64deaafbbc52d5d407afaa22d493d687c538b7f"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-controllable-state/-/react-use-controllable-state-1.0.0.tgz#a64deaafbbc52d5d407afaa22d493d687c538b7f"
|
||||||
@@ -2226,19 +2177,13 @@
|
|||||||
"@babel/runtime" "^7.13.10"
|
"@babel/runtime" "^7.13.10"
|
||||||
"@radix-ui/react-use-callback-ref" "1.0.0"
|
"@radix-ui/react-use-callback-ref" "1.0.0"
|
||||||
|
|
||||||
"@radix-ui/react-use-controllable-state@1.1.0":
|
"@radix-ui/react-use-escape-keydown@1.0.2":
|
||||||
version "1.1.0"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-controllable-state/-/react-use-controllable-state-1.1.0.tgz#1321446857bb786917df54c0d4d084877aab04b0"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-escape-keydown/-/react-use-escape-keydown-1.0.2.tgz#09ab6455ab240b4f0a61faf06d4e5132c4d639f6"
|
||||||
integrity sha512-MtfMVJiSr2NjzS0Aa90NPTnvTSg6C/JLCV7ma0W6+OMV78vd8OyRpID+Ng9LxzsPbLeuBnWBA1Nq30AtBIDChw==
|
integrity sha512-DXGim3x74WgUv+iMNCF+cAo8xUHHeqvjx8zs7trKf+FkQKPQXLk2sX7Gx1ysH7Q76xCpZuxIJE7HLPxRE+Q+GA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@radix-ui/react-use-callback-ref" "1.1.0"
|
"@babel/runtime" "^7.13.10"
|
||||||
|
"@radix-ui/react-use-callback-ref" "1.0.0"
|
||||||
"@radix-ui/react-use-escape-keydown@1.1.0":
|
|
||||||
version "1.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-escape-keydown/-/react-use-escape-keydown-1.1.0.tgz#31a5b87c3b726504b74e05dac1edce7437b98754"
|
|
||||||
integrity sha512-L7vwWlR1kTTQ3oh7g1O0CBF3YCyyTj8NmhLR+phShpyA50HCfBFKVJTpshm9PzLiKmehsrQzTYTpX9HvmC9rhw==
|
|
||||||
dependencies:
|
|
||||||
"@radix-ui/react-use-callback-ref" "1.1.0"
|
|
||||||
|
|
||||||
"@radix-ui/react-use-layout-effect@1.0.0":
|
"@radix-ui/react-use-layout-effect@1.0.0":
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
@@ -2247,29 +2192,28 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "^7.13.10"
|
"@babel/runtime" "^7.13.10"
|
||||||
|
|
||||||
"@radix-ui/react-use-layout-effect@1.1.0":
|
"@radix-ui/react-use-rect@1.0.0":
|
||||||
version "1.1.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-layout-effect/-/react-use-layout-effect-1.1.0.tgz#3c2c8ce04827b26a39e442ff4888d9212268bd27"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-rect/-/react-use-rect-1.0.0.tgz#b040cc88a4906b78696cd3a32b075ed5b1423b3e"
|
||||||
integrity sha512-+FPE0rOdziWSrH9athwI1R0HDVbWlEhd+FR+aSDk4uWGmSJ9Z54sdZVDQPZAinJhJXwfT+qnj969mCsT2gfm5w==
|
integrity sha512-TB7pID8NRMEHxb/qQJpvSt3hQU4sqNPM1VCTjTRjEOa7cEop/QMuq8S6fb/5Tsz64kqSvB9WnwsDHtjnrM9qew==
|
||||||
|
|
||||||
"@radix-ui/react-use-rect@1.1.0":
|
|
||||||
version "1.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-rect/-/react-use-rect-1.1.0.tgz#13b25b913bd3e3987cc9b073a1a164bb1cf47b88"
|
|
||||||
integrity sha512-0Fmkebhr6PiseyZlYAOtLS+nb7jLmpqTrJyv61Pe68MKYW6OWdRE2kI70TaYY27u7H0lajqM3hSMMLFq18Z7nQ==
|
|
||||||
dependencies:
|
dependencies:
|
||||||
"@radix-ui/rect" "1.1.0"
|
"@babel/runtime" "^7.13.10"
|
||||||
|
"@radix-ui/rect" "1.0.0"
|
||||||
|
|
||||||
"@radix-ui/react-use-size@1.1.0":
|
"@radix-ui/react-use-size@1.0.0":
|
||||||
version "1.1.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-size/-/react-use-size-1.1.0.tgz#b4dba7fbd3882ee09e8d2a44a3eed3a7e555246b"
|
resolved "https://registry.yarnpkg.com/@radix-ui/react-use-size/-/react-use-size-1.0.0.tgz#a0b455ac826749419f6354dc733e2ca465054771"
|
||||||
integrity sha512-XW3/vWuIXHa+2Uwcc2ABSfcCledmXhhQPlGbfcRXbiUQI5Icjcg19BGCZVKKInYbvUCut/ufbbLLPFC5cbb1hw==
|
integrity sha512-imZ3aYcoYCKhhgNpkNDh/aTiU05qw9hX+HHI1QDBTyIlcFjgeFlKKySNGMwTp7nYFLQg/j0VA2FmCY4WPDDHMg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@radix-ui/react-use-layout-effect" "1.1.0"
|
"@babel/runtime" "^7.13.10"
|
||||||
|
"@radix-ui/react-use-layout-effect" "1.0.0"
|
||||||
|
|
||||||
"@radix-ui/rect@1.1.0":
|
"@radix-ui/rect@1.0.0":
|
||||||
version "1.1.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@radix-ui/rect/-/rect-1.1.0.tgz#f817d1d3265ac5415dadc67edab30ae196696438"
|
resolved "https://registry.yarnpkg.com/@radix-ui/rect/-/rect-1.0.0.tgz#0dc8e6a829ea2828d53cbc94b81793ba6383bf3c"
|
||||||
integrity sha512-A9+lCBZoaMJlVKcRBz2YByCG+Cp2t6nAnMnNba+XiWxnj6r4JUFqfsgwocMBZU9LPtdxC6wB56ySYpc7LQIoJg==
|
integrity sha512-d0O68AYy/9oeEy1DdC07bz1/ZXX+DqCskRd3i4JzLSTXwefzaepQrKjXC7aNM8lTHjFLDO0pDgaEiQ7jEk+HVg==
|
||||||
|
dependencies:
|
||||||
|
"@babel/runtime" "^7.13.10"
|
||||||
|
|
||||||
"@sideway/address@^4.1.3":
|
"@sideway/address@^4.1.3":
|
||||||
version "4.1.4"
|
version "4.1.4"
|
||||||
@@ -3008,7 +2952,7 @@ argparse@^2.0.1:
|
|||||||
resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38"
|
resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38"
|
||||||
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==
|
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==
|
||||||
|
|
||||||
aria-hidden@^1.2.4:
|
aria-hidden@^1.1.1:
|
||||||
version "1.2.4"
|
version "1.2.4"
|
||||||
resolved "https://registry.yarnpkg.com/aria-hidden/-/aria-hidden-1.2.4.tgz#b78e383fdbc04d05762c78b4a25a501e736c4522"
|
resolved "https://registry.yarnpkg.com/aria-hidden/-/aria-hidden-1.2.4.tgz#b78e383fdbc04d05762c78b4a25a501e736c4522"
|
||||||
integrity sha512-y+CcFFwelSXpLZk/7fMB2mUbGtX9lKycf1MWJ7CaTIERyitVlyQx6C+sxcROU2BAJ24OiZyK+8wj2i8AlBoS3A==
|
integrity sha512-y+CcFFwelSXpLZk/7fMB2mUbGtX9lKycf1MWJ7CaTIERyitVlyQx6C+sxcROU2BAJ24OiZyK+8wj2i8AlBoS3A==
|
||||||
@@ -7539,7 +7483,7 @@ react-loadable-ssr-addon-v5-slorber@^1.0.1:
|
|||||||
"@types/react" "*"
|
"@types/react" "*"
|
||||||
prop-types "^15.6.2"
|
prop-types "^15.6.2"
|
||||||
|
|
||||||
react-remove-scroll-bar@^2.3.7:
|
react-remove-scroll-bar@^2.3.3:
|
||||||
version "2.3.8"
|
version "2.3.8"
|
||||||
resolved "https://registry.yarnpkg.com/react-remove-scroll-bar/-/react-remove-scroll-bar-2.3.8.tgz#99c20f908ee467b385b68a3469b4a3e750012223"
|
resolved "https://registry.yarnpkg.com/react-remove-scroll-bar/-/react-remove-scroll-bar-2.3.8.tgz#99c20f908ee467b385b68a3469b4a3e750012223"
|
||||||
integrity sha512-9r+yi9+mgU33AKcj6IbT9oRCO78WriSj6t/cF8DWBZJ9aOGPOTEDvdUDz1FwKim7QXWwmHqtdHnRJfhAxEG46Q==
|
integrity sha512-9r+yi9+mgU33AKcj6IbT9oRCO78WriSj6t/cF8DWBZJ9aOGPOTEDvdUDz1FwKim7QXWwmHqtdHnRJfhAxEG46Q==
|
||||||
@@ -7547,16 +7491,16 @@ react-remove-scroll-bar@^2.3.7:
|
|||||||
react-style-singleton "^2.2.2"
|
react-style-singleton "^2.2.2"
|
||||||
tslib "^2.0.0"
|
tslib "^2.0.0"
|
||||||
|
|
||||||
react-remove-scroll@^2.6.3:
|
react-remove-scroll@2.5.5:
|
||||||
version "2.6.3"
|
version "2.5.5"
|
||||||
resolved "https://registry.yarnpkg.com/react-remove-scroll/-/react-remove-scroll-2.6.3.tgz#df02cde56d5f2731e058531f8ffd7f9adec91ac2"
|
resolved "https://registry.yarnpkg.com/react-remove-scroll/-/react-remove-scroll-2.5.5.tgz#1e31a1260df08887a8a0e46d09271b52b3a37e77"
|
||||||
integrity sha512-pnAi91oOk8g8ABQKGF5/M9qxmmOPxaAnopyTHYfqYEwJhyFrbbBtHuSgtKEoH0jpcxx5o3hXqH1mNd9/Oi+8iQ==
|
integrity sha512-ImKhrzJJsyXJfBZ4bzu8Bwpka14c/fQt0k+cyFp/PBhTfyDnU5hjOtM4AG/0AMyy8oKzOTR0lDgJIM7pYXI0kw==
|
||||||
dependencies:
|
dependencies:
|
||||||
react-remove-scroll-bar "^2.3.7"
|
react-remove-scroll-bar "^2.3.3"
|
||||||
react-style-singleton "^2.2.3"
|
react-style-singleton "^2.2.1"
|
||||||
tslib "^2.1.0"
|
tslib "^2.1.0"
|
||||||
use-callback-ref "^1.3.3"
|
use-callback-ref "^1.3.0"
|
||||||
use-sidecar "^1.1.3"
|
use-sidecar "^1.1.2"
|
||||||
|
|
||||||
react-router-config@^5.1.1:
|
react-router-config@^5.1.1:
|
||||||
version "5.1.1"
|
version "5.1.1"
|
||||||
@@ -7599,7 +7543,7 @@ react-simple-code-editor@^0.10.0:
|
|||||||
resolved "https://registry.yarnpkg.com/react-simple-code-editor/-/react-simple-code-editor-0.10.0.tgz#73e7ac550a928069715482aeb33ccba36efe2373"
|
resolved "https://registry.yarnpkg.com/react-simple-code-editor/-/react-simple-code-editor-0.10.0.tgz#73e7ac550a928069715482aeb33ccba36efe2373"
|
||||||
integrity sha512-bL5W5mAxSW6+cLwqqVWY47Silqgy2DKDTR4hDBrLrUqC5BXc29YVx17l2IZk5v36VcDEq1Bszu2oHm1qBwKqBA==
|
integrity sha512-bL5W5mAxSW6+cLwqqVWY47Silqgy2DKDTR4hDBrLrUqC5BXc29YVx17l2IZk5v36VcDEq1Bszu2oHm1qBwKqBA==
|
||||||
|
|
||||||
react-style-singleton@^2.2.2, react-style-singleton@^2.2.3:
|
react-style-singleton@^2.2.1, react-style-singleton@^2.2.2:
|
||||||
version "2.2.3"
|
version "2.2.3"
|
||||||
resolved "https://registry.yarnpkg.com/react-style-singleton/-/react-style-singleton-2.2.3.tgz#4265608be69a4d70cfe3047f2c6c88b2c3ace388"
|
resolved "https://registry.yarnpkg.com/react-style-singleton/-/react-style-singleton-2.2.3.tgz#4265608be69a4d70cfe3047f2c6c88b2c3ace388"
|
||||||
integrity sha512-b6jSvxvVnyptAiLjbkWLE/lOnR4lfTtDAl+eUC7RZy+QQWc6wRzIV2CE6xBuMmDxc2qIihtDCZD5NPOFl7fRBQ==
|
integrity sha512-b6jSvxvVnyptAiLjbkWLE/lOnR4lfTtDAl+eUC7RZy+QQWc6wRzIV2CE6xBuMmDxc2qIihtDCZD5NPOFl7fRBQ==
|
||||||
@@ -8861,7 +8805,7 @@ url-parse-lax@^3.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
prepend-http "^2.0.0"
|
prepend-http "^2.0.0"
|
||||||
|
|
||||||
use-callback-ref@^1.3.3:
|
use-callback-ref@^1.3.0:
|
||||||
version "1.3.3"
|
version "1.3.3"
|
||||||
resolved "https://registry.yarnpkg.com/use-callback-ref/-/use-callback-ref-1.3.3.tgz#98d9fab067075841c5b2c6852090d5d0feabe2bf"
|
resolved "https://registry.yarnpkg.com/use-callback-ref/-/use-callback-ref-1.3.3.tgz#98d9fab067075841c5b2c6852090d5d0feabe2bf"
|
||||||
integrity sha512-jQL3lRnocaFtu3V00JToYz/4QkNWswxijDaCVNZRiRTO3HQDLsdu1ZtmIUvV4yPp+rvWm5j0y0TG/S61cuijTg==
|
integrity sha512-jQL3lRnocaFtu3V00JToYz/4QkNWswxijDaCVNZRiRTO3HQDLsdu1ZtmIUvV4yPp+rvWm5j0y0TG/S61cuijTg==
|
||||||
@@ -8885,7 +8829,7 @@ use-latest@^1.2.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
use-isomorphic-layout-effect "^1.1.1"
|
use-isomorphic-layout-effect "^1.1.1"
|
||||||
|
|
||||||
use-sidecar@^1.1.3:
|
use-sidecar@^1.1.2:
|
||||||
version "1.1.3"
|
version "1.1.3"
|
||||||
resolved "https://registry.yarnpkg.com/use-sidecar/-/use-sidecar-1.1.3.tgz#10e7fd897d130b896e2c546c63a5e8233d00efdb"
|
resolved "https://registry.yarnpkg.com/use-sidecar/-/use-sidecar-1.1.3.tgz#10e7fd897d130b896e2c546c63a5e8233d00efdb"
|
||||||
integrity sha512-Fedw0aZvkhynoPYlA5WXrMCAMm+nSWdZt6lzJQ7Ok8S6Q+VsHmHpRWndVRJ8Be0ZbkfPc5LRYH+5XrzXcEeLRQ==
|
integrity sha512-Fedw0aZvkhynoPYlA5WXrMCAMm+nSWdZt6lzJQ7Ok8S6Q+VsHmHpRWndVRJ8Be0ZbkfPc5LRYH+5XrzXcEeLRQ==
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
version: "3.8"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
excalidraw:
|
excalidraw:
|
||||||
build:
|
build:
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:packages": "yarn --cwd ../../ build:packages",
|
"build:workspace": "yarn workspace @excalidraw/excalidraw run build:esm && yarn copy:assets",
|
||||||
"build:workspace": "yarn build:packages && yarn copy:assets",
|
|
||||||
"copy:assets": "cp -r ../../packages/excalidraw/dist/prod/fonts ./public",
|
"copy:assets": "cp -r ../../packages/excalidraw/dist/prod/fonts ./public",
|
||||||
"dev": "yarn build:workspace && next dev -p 3005",
|
"dev": "yarn build:workspace && next dev -p 3005",
|
||||||
"build": "yarn build:workspace && next build",
|
"build": "yarn build:workspace && next build",
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
import Script from "next/script";
|
import Script from "next/script";
|
||||||
|
|
||||||
import "../common.scss";
|
import "../common.scss";
|
||||||
|
|
||||||
// Since client components get prerenderd on server as well hence importing the excalidraw stuff dynamically
|
// Since client components get prerenderd on server as well hence importing the excalidraw stuff dynamically
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import * as excalidrawLib from "@excalidraw/excalidraw";
|
import * as excalidrawLib from "@excalidraw/excalidraw";
|
||||||
import { Excalidraw } from "@excalidraw/excalidraw";
|
import { Excalidraw } from "@excalidraw/excalidraw";
|
||||||
|
import App from "../../with-script-in-browser/components/ExampleApp";
|
||||||
|
|
||||||
import "@excalidraw/excalidraw/index.css";
|
import "@excalidraw/excalidraw/index.css";
|
||||||
|
|
||||||
import App from "../../with-script-in-browser/components/ExampleApp";
|
|
||||||
|
|
||||||
const ExcalidrawWrapper: React.FC = () => {
|
const ExcalidrawWrapper: React.FC = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
|
|
||||||
import "../common.scss";
|
import "../common.scss";
|
||||||
|
|
||||||
// Since client components get prerenderd on server as well hence importing the excalidraw stuff dynamically
|
// Since client components get prerenderd on server as well hence importing the excalidraw stuff dynamically
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import type * as TExcalidraw from "@excalidraw/excalidraw";
|
import type * as TExcalidraw from "@excalidraw/excalidraw";
|
||||||
import type { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types";
|
import type { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types";
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
transform: none;
|
transform: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.excalidraw .selected-shape-actions {
|
.excalidraw .panelColumn {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { nanoid } from "nanoid";
|
|
||||||
import React, {
|
import React, {
|
||||||
useEffect,
|
useEffect,
|
||||||
useState,
|
useState,
|
||||||
@@ -7,24 +6,13 @@ import React, {
|
|||||||
Children,
|
Children,
|
||||||
cloneElement,
|
cloneElement,
|
||||||
} from "react";
|
} from "react";
|
||||||
|
import ExampleSidebar from "./sidebar/ExampleSidebar";
|
||||||
|
|
||||||
import type * as TExcalidraw from "@excalidraw/excalidraw";
|
import type * as TExcalidraw from "@excalidraw/excalidraw";
|
||||||
import type { ImportedLibraryData } from "@excalidraw/excalidraw/data/types";
|
|
||||||
import type {
|
|
||||||
NonDeletedExcalidrawElement,
|
|
||||||
Theme,
|
|
||||||
} from "@excalidraw/excalidraw/element/types";
|
|
||||||
import type {
|
|
||||||
AppState,
|
|
||||||
BinaryFileData,
|
|
||||||
ExcalidrawImperativeAPI,
|
|
||||||
ExcalidrawInitialDataState,
|
|
||||||
Gesture,
|
|
||||||
LibraryItems,
|
|
||||||
PointerDownState as ExcalidrawPointerDownState,
|
|
||||||
} from "@excalidraw/excalidraw/types";
|
|
||||||
|
|
||||||
import initialData from "../initialData";
|
import { nanoid } from "nanoid";
|
||||||
|
|
||||||
|
import type { ResolvablePromise } from "../utils";
|
||||||
import {
|
import {
|
||||||
resolvablePromise,
|
resolvablePromise,
|
||||||
distance2d,
|
distance2d,
|
||||||
@@ -35,12 +23,25 @@ import {
|
|||||||
|
|
||||||
import CustomFooter from "./CustomFooter";
|
import CustomFooter from "./CustomFooter";
|
||||||
import MobileFooter from "./MobileFooter";
|
import MobileFooter from "./MobileFooter";
|
||||||
import ExampleSidebar from "./sidebar/ExampleSidebar";
|
import initialData from "../initialData";
|
||||||
|
|
||||||
|
import type {
|
||||||
|
AppState,
|
||||||
|
BinaryFileData,
|
||||||
|
ExcalidrawImperativeAPI,
|
||||||
|
ExcalidrawInitialDataState,
|
||||||
|
Gesture,
|
||||||
|
LibraryItems,
|
||||||
|
PointerDownState as ExcalidrawPointerDownState,
|
||||||
|
} from "@excalidraw/excalidraw/types";
|
||||||
|
import type {
|
||||||
|
NonDeletedExcalidrawElement,
|
||||||
|
Theme,
|
||||||
|
} from "@excalidraw/excalidraw/element/types";
|
||||||
|
import type { ImportedLibraryData } from "@excalidraw/excalidraw/data/types";
|
||||||
|
|
||||||
import "./ExampleApp.scss";
|
import "./ExampleApp.scss";
|
||||||
|
|
||||||
import type { ResolvablePromise } from "../utils";
|
|
||||||
|
|
||||||
type Comment = {
|
type Comment = {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
@@ -104,7 +105,6 @@ export default function ExampleApp({
|
|||||||
const [viewModeEnabled, setViewModeEnabled] = useState(false);
|
const [viewModeEnabled, setViewModeEnabled] = useState(false);
|
||||||
const [zenModeEnabled, setZenModeEnabled] = useState(false);
|
const [zenModeEnabled, setZenModeEnabled] = useState(false);
|
||||||
const [gridModeEnabled, setGridModeEnabled] = useState(false);
|
const [gridModeEnabled, setGridModeEnabled] = useState(false);
|
||||||
const [renderScrollbars, setRenderScrollbars] = useState(false);
|
|
||||||
const [blobUrl, setBlobUrl] = useState<string>("");
|
const [blobUrl, setBlobUrl] = useState<string>("");
|
||||||
const [canvasUrl, setCanvasUrl] = useState<string>("");
|
const [canvasUrl, setCanvasUrl] = useState<string>("");
|
||||||
const [exportWithDarkMode, setExportWithDarkMode] = useState(false);
|
const [exportWithDarkMode, setExportWithDarkMode] = useState(false);
|
||||||
@@ -193,7 +193,6 @@ export default function ExampleApp({
|
|||||||
}) => setPointerData(payload),
|
}) => setPointerData(payload),
|
||||||
viewModeEnabled,
|
viewModeEnabled,
|
||||||
zenModeEnabled,
|
zenModeEnabled,
|
||||||
renderScrollbars,
|
|
||||||
gridModeEnabled,
|
gridModeEnabled,
|
||||||
theme,
|
theme,
|
||||||
name: "Custom name of drawing",
|
name: "Custom name of drawing",
|
||||||
@@ -712,14 +711,6 @@ export default function ExampleApp({
|
|||||||
/>
|
/>
|
||||||
Grid mode
|
Grid mode
|
||||||
</label>
|
</label>
|
||||||
<label>
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
checked={renderScrollbars}
|
|
||||||
onChange={() => setRenderScrollbars(!renderScrollbars)}
|
|
||||||
/>
|
|
||||||
Render scrollbars
|
|
||||||
</label>
|
|
||||||
<label>
|
<label>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import type * as TExcalidraw from "@excalidraw/excalidraw";
|
|
||||||
import type { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types";
|
import type { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types";
|
||||||
|
|
||||||
import CustomFooter from "./CustomFooter";
|
import CustomFooter from "./CustomFooter";
|
||||||
|
import type * as TExcalidraw from "@excalidraw/excalidraw";
|
||||||
|
|
||||||
const MobileFooter = ({
|
const MobileFooter = ({
|
||||||
excalidrawAPI,
|
excalidrawAPI,
|
||||||
@@ -12,10 +10,10 @@ const MobileFooter = ({
|
|||||||
excalidrawAPI: ExcalidrawImperativeAPI;
|
excalidrawAPI: ExcalidrawImperativeAPI;
|
||||||
excalidrawLib: typeof TExcalidraw;
|
excalidrawLib: typeof TExcalidraw;
|
||||||
}) => {
|
}) => {
|
||||||
const { useEditorInterface, Footer } = excalidrawLib;
|
const { useDevice, Footer } = excalidrawLib;
|
||||||
|
|
||||||
const editorInterface = useEditorInterface();
|
const device = useDevice();
|
||||||
if (editorInterface.formFactor === "phone") {
|
if (device.editor.isMobile) {
|
||||||
return (
|
return (
|
||||||
<Footer>
|
<Footer>
|
||||||
<CustomFooter
|
<CustomFooter
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
|
||||||
import "./ExampleSidebar.scss";
|
import "./ExampleSidebar.scss";
|
||||||
|
|
||||||
export default function Sidebar({ children }: { children: React.ReactNode }) {
|
export default function Sidebar({ children }: { children: React.ReactNode }) {
|
||||||
|
|||||||
@@ -12,8 +12,9 @@
|
|||||||
<script>
|
<script>
|
||||||
window.name = "codesandbox";
|
window.name = "codesandbox";
|
||||||
window.EXCALIDRAW_ASSET_PATH =
|
window.EXCALIDRAW_ASSET_PATH =
|
||||||
"https://esm.sh/@excalidraw/excalidraw@0.18.0/dist/prod/";
|
"https://esm.sh/@excalidraw/excalidraw@0.18.0-rc.5/dist/prod/";
|
||||||
</script>
|
</script>
|
||||||
|
<link rel="stylesheet" href="/dist/dev/index.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
|
import App from "./components/ExampleApp";
|
||||||
import React, { StrictMode } from "react";
|
import React, { StrictMode } from "react";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
|
|
||||||
import "@excalidraw/excalidraw/index.css";
|
|
||||||
|
|
||||||
import type * as TExcalidraw from "@excalidraw/excalidraw";
|
import type * as TExcalidraw from "@excalidraw/excalidraw";
|
||||||
|
|
||||||
import App from "./components/ExampleApp";
|
import "@excalidraw/excalidraw/index.css";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
|
|||||||
@@ -3,20 +3,18 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@excalidraw/excalidraw": "*",
|
|
||||||
"browser-fs-access": "0.38.0",
|
|
||||||
"react": "19.0.0",
|
"react": "19.0.0",
|
||||||
"react-dom": "19.0.0"
|
"react-dom": "19.0.0",
|
||||||
|
"@excalidraw/excalidraw": "0.18.0-rc.5",
|
||||||
|
"browser-fs-access": "0.29.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^5",
|
"vite": "5.0.12",
|
||||||
"vite": "5.0.12"
|
"typescript": "^5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview --port 5002",
|
"build:preview": "yarn build && vite preview --port 5002"
|
||||||
"build:preview": "yarn build && yarn preview",
|
|
||||||
"build:packages": "yarn --cwd ../../ build:packages"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import { MIME_TYPES } from "@excalidraw/excalidraw";
|
|
||||||
import { fileOpen as _fileOpen } from "browser-fs-access";
|
|
||||||
import { unstable_batchedUpdates } from "react-dom";
|
import { unstable_batchedUpdates } from "react-dom";
|
||||||
|
import { fileOpen as _fileOpen } from "browser-fs-access";
|
||||||
|
import { MIME_TYPES } from "@excalidraw/excalidraw";
|
||||||
|
|
||||||
type FILE_EXTENSION = Exclude<keyof typeof MIME_TYPES, "binary">;
|
type FILE_EXTENSION = Exclude<keyof typeof MIME_TYPES, "binary">;
|
||||||
|
|
||||||
|
const INPUT_CHANGE_INTERVAL_MS = 500;
|
||||||
|
|
||||||
export type ResolvablePromise<T> = Promise<T> & {
|
export type ResolvablePromise<T> = Promise<T> & {
|
||||||
resolve: [T] extends [undefined] ? (value?: T) => void : (value: T) => void;
|
resolve: [T] extends [undefined] ? (value?: T) => void : (value: T) => void;
|
||||||
reject: (error: Error) => void;
|
reject: (error: Error) => void;
|
||||||
@@ -52,6 +54,40 @@ export const fileOpen = <M extends boolean | undefined = false>(opts: {
|
|||||||
extensions,
|
extensions,
|
||||||
mimeTypes,
|
mimeTypes,
|
||||||
multiple: opts.multiple ?? false,
|
multiple: opts.multiple ?? false,
|
||||||
|
legacySetup: (resolve, reject, input) => {
|
||||||
|
const scheduleRejection = debounce(reject, INPUT_CHANGE_INTERVAL_MS);
|
||||||
|
const focusHandler = () => {
|
||||||
|
checkForFile();
|
||||||
|
document.addEventListener("keyup", scheduleRejection);
|
||||||
|
document.addEventListener("pointerup", scheduleRejection);
|
||||||
|
scheduleRejection();
|
||||||
|
};
|
||||||
|
const checkForFile = () => {
|
||||||
|
// this hack might not work when expecting multiple files
|
||||||
|
if (input.files?.length) {
|
||||||
|
const ret = opts.multiple ? [...input.files] : input.files[0];
|
||||||
|
resolve(ret as RetType);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
window.addEventListener("focus", focusHandler);
|
||||||
|
});
|
||||||
|
const interval = window.setInterval(() => {
|
||||||
|
checkForFile();
|
||||||
|
}, INPUT_CHANGE_INTERVAL_MS);
|
||||||
|
return (rejectPromise) => {
|
||||||
|
clearInterval(interval);
|
||||||
|
scheduleRejection.cancel();
|
||||||
|
window.removeEventListener("focus", focusHandler);
|
||||||
|
document.removeEventListener("keyup", scheduleRejection);
|
||||||
|
document.removeEventListener("pointerup", scheduleRejection);
|
||||||
|
if (rejectPromise) {
|
||||||
|
// so that something is shown in console if we need to debug this
|
||||||
|
console.warn("Opening the file was canceled (legacy-fs).");
|
||||||
|
rejectPromise(new Error("Request Aborted"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
}) as Promise<RetType>;
|
}) as Promise<RetType>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"outputDirectory": "dist",
|
"outputDirectory": "dist",
|
||||||
"installCommand": "yarn install",
|
"installCommand": "yarn install"
|
||||||
"buildCommand": "yarn build:packages && yarn build"
|
|
||||||
}
|
}
|
||||||
|
|||||||
+134
-267
@@ -1,29 +1,40 @@
|
|||||||
|
import polyfill from "@excalidraw/excalidraw/polyfill";
|
||||||
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
|
import { trackEvent } from "@excalidraw/excalidraw/analytics";
|
||||||
|
import { getDefaultAppState } from "@excalidraw/excalidraw/appState";
|
||||||
|
import { ErrorDialog } from "@excalidraw/excalidraw/components/ErrorDialog";
|
||||||
|
import { TopErrorBoundary } from "./components/TopErrorBoundary";
|
||||||
|
import {
|
||||||
|
APP_NAME,
|
||||||
|
EVENT,
|
||||||
|
THEME,
|
||||||
|
TITLE_TIMEOUT,
|
||||||
|
VERSION_TIMEOUT,
|
||||||
|
} from "@excalidraw/excalidraw/constants";
|
||||||
|
import { loadFromBlob } from "@excalidraw/excalidraw/data/blob";
|
||||||
|
import type {
|
||||||
|
FileId,
|
||||||
|
NonDeletedExcalidrawElement,
|
||||||
|
OrderedExcalidrawElement,
|
||||||
|
} from "@excalidraw/excalidraw/element/types";
|
||||||
|
import { useCallbackRefState } from "@excalidraw/excalidraw/hooks/useCallbackRefState";
|
||||||
|
import { t } from "@excalidraw/excalidraw/i18n";
|
||||||
import {
|
import {
|
||||||
Excalidraw,
|
Excalidraw,
|
||||||
LiveCollaborationTrigger,
|
LiveCollaborationTrigger,
|
||||||
TTDDialogTrigger,
|
TTDDialogTrigger,
|
||||||
CaptureUpdateAction,
|
CaptureUpdateAction,
|
||||||
reconcileElements,
|
reconcileElements,
|
||||||
useEditorInterface,
|
|
||||||
ExcalidrawAPIProvider,
|
|
||||||
useExcalidrawAPI,
|
|
||||||
} from "@excalidraw/excalidraw";
|
} from "@excalidraw/excalidraw";
|
||||||
import { trackEvent } from "@excalidraw/excalidraw/analytics";
|
import type {
|
||||||
import { getDefaultAppState } from "@excalidraw/excalidraw/appState";
|
AppState,
|
||||||
|
ExcalidrawImperativeAPI,
|
||||||
|
BinaryFiles,
|
||||||
|
ExcalidrawInitialDataState,
|
||||||
|
UIAppState,
|
||||||
|
} from "@excalidraw/excalidraw/types";
|
||||||
|
import type { ResolvablePromise } from "@excalidraw/excalidraw/utils";
|
||||||
import {
|
import {
|
||||||
CommandPalette,
|
|
||||||
DEFAULT_CATEGORIES,
|
|
||||||
} from "@excalidraw/excalidraw/components/CommandPalette/CommandPalette";
|
|
||||||
import { ErrorDialog } from "@excalidraw/excalidraw/components/ErrorDialog";
|
|
||||||
import { OverwriteConfirmDialog } from "@excalidraw/excalidraw/components/OverwriteConfirm/OverwriteConfirm";
|
|
||||||
import { openConfirmModal } from "@excalidraw/excalidraw/components/OverwriteConfirm/OverwriteConfirmState";
|
|
||||||
import { ShareableLinkDialog } from "@excalidraw/excalidraw/components/ShareableLinkDialog";
|
|
||||||
import Trans from "@excalidraw/excalidraw/components/Trans";
|
|
||||||
import {
|
|
||||||
APP_NAME,
|
|
||||||
EVENT,
|
|
||||||
THEME,
|
|
||||||
VERSION_TIMEOUT,
|
|
||||||
debounce,
|
debounce,
|
||||||
getVersion,
|
getVersion,
|
||||||
getFrame,
|
getFrame,
|
||||||
@@ -31,13 +42,75 @@ import {
|
|||||||
preventUnload,
|
preventUnload,
|
||||||
resolvablePromise,
|
resolvablePromise,
|
||||||
isRunningInIframe,
|
isRunningInIframe,
|
||||||
isDevEnv,
|
} from "@excalidraw/excalidraw/utils";
|
||||||
} from "@excalidraw/common";
|
import {
|
||||||
import polyfill from "@excalidraw/excalidraw/polyfill";
|
FIREBASE_STORAGE_PREFIXES,
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
isExcalidrawPlusSignedUser,
|
||||||
import { loadFromBlob } from "@excalidraw/excalidraw/data/blob";
|
STORAGE_KEYS,
|
||||||
import { t } from "@excalidraw/excalidraw/i18n";
|
SYNC_BROWSER_TABS_TIMEOUT,
|
||||||
|
} from "./app_constants";
|
||||||
|
import type { CollabAPI } from "./collab/Collab";
|
||||||
|
import Collab, {
|
||||||
|
collabAPIAtom,
|
||||||
|
isCollaboratingAtom,
|
||||||
|
isOfflineAtom,
|
||||||
|
} from "./collab/Collab";
|
||||||
|
import {
|
||||||
|
exportToBackend,
|
||||||
|
getCollaborationLinkData,
|
||||||
|
isCollaborationLink,
|
||||||
|
loadScene,
|
||||||
|
} from "./data";
|
||||||
|
import {
|
||||||
|
importFromLocalStorage,
|
||||||
|
importUsernameFromLocalStorage,
|
||||||
|
} from "./data/localStorage";
|
||||||
|
import CustomStats from "./CustomStats";
|
||||||
|
import type { RestoredDataState } from "@excalidraw/excalidraw/data/restore";
|
||||||
|
import { restore, restoreAppState } from "@excalidraw/excalidraw/data/restore";
|
||||||
|
import {
|
||||||
|
ExportToExcalidrawPlus,
|
||||||
|
exportToExcalidrawPlus,
|
||||||
|
} from "./components/ExportToExcalidrawPlus";
|
||||||
|
import { updateStaleImageStatuses } from "./data/FileManager";
|
||||||
|
import { newElementWith } from "@excalidraw/excalidraw/element/mutateElement";
|
||||||
|
import { isInitializedImageElement } from "@excalidraw/excalidraw/element/typeChecks";
|
||||||
|
import { loadFilesFromFirebase } from "./data/firebase";
|
||||||
|
import {
|
||||||
|
LibraryIndexedDBAdapter,
|
||||||
|
LibraryLocalStorageMigrationAdapter,
|
||||||
|
LocalData,
|
||||||
|
} from "./data/LocalData";
|
||||||
|
import { isBrowserStorageStateNewer } from "./data/tabSync";
|
||||||
|
import clsx from "clsx";
|
||||||
|
import {
|
||||||
|
parseLibraryTokensFromUrl,
|
||||||
|
useHandleLibrary,
|
||||||
|
} from "@excalidraw/excalidraw/data/library";
|
||||||
|
import { AppMainMenu } from "./components/AppMainMenu";
|
||||||
|
import { AppWelcomeScreen } from "./components/AppWelcomeScreen";
|
||||||
|
import { AppFooter } from "./components/AppFooter";
|
||||||
|
import {
|
||||||
|
Provider,
|
||||||
|
useAtom,
|
||||||
|
useAtomValue,
|
||||||
|
useAtomWithInitialValue,
|
||||||
|
appJotaiStore,
|
||||||
|
} from "./app-jotai";
|
||||||
|
|
||||||
|
import "./index.scss";
|
||||||
|
import type { ResolutionType } from "@excalidraw/excalidraw/utility-types";
|
||||||
|
import { ShareableLinkDialog } from "@excalidraw/excalidraw/components/ShareableLinkDialog";
|
||||||
|
import { openConfirmModal } from "@excalidraw/excalidraw/components/OverwriteConfirm/OverwriteConfirmState";
|
||||||
|
import { OverwriteConfirmDialog } from "@excalidraw/excalidraw/components/OverwriteConfirm/OverwriteConfirm";
|
||||||
|
import Trans from "@excalidraw/excalidraw/components/Trans";
|
||||||
|
import { ShareDialog, shareDialogStateAtom } from "./share/ShareDialog";
|
||||||
|
import CollabError, { collabErrorIndicatorAtom } from "./collab/CollabError";
|
||||||
|
import type { RemoteExcalidrawElement } from "@excalidraw/excalidraw/data/reconcile";
|
||||||
|
import {
|
||||||
|
CommandPalette,
|
||||||
|
DEFAULT_CATEGORIES,
|
||||||
|
} from "@excalidraw/excalidraw/components/CommandPalette/CommandPalette";
|
||||||
import {
|
import {
|
||||||
GithubIcon,
|
GithubIcon,
|
||||||
XBrandIcon,
|
XBrandIcon,
|
||||||
@@ -48,90 +121,6 @@ import {
|
|||||||
share,
|
share,
|
||||||
youtubeIcon,
|
youtubeIcon,
|
||||||
} from "@excalidraw/excalidraw/components/icons";
|
} from "@excalidraw/excalidraw/components/icons";
|
||||||
import { isElementLink } from "@excalidraw/element";
|
|
||||||
import {
|
|
||||||
bumpElementVersions,
|
|
||||||
restoreAppState,
|
|
||||||
restoreElements,
|
|
||||||
} from "@excalidraw/excalidraw/data/restore";
|
|
||||||
import { newElementWith } from "@excalidraw/element";
|
|
||||||
import { isInitializedImageElement } from "@excalidraw/element";
|
|
||||||
import clsx from "clsx";
|
|
||||||
import {
|
|
||||||
parseLibraryTokensFromUrl,
|
|
||||||
useHandleLibrary,
|
|
||||||
} from "@excalidraw/excalidraw/data/library";
|
|
||||||
|
|
||||||
import type { RemoteExcalidrawElement } from "@excalidraw/excalidraw/data/reconcile";
|
|
||||||
import type { RestoredDataState } from "@excalidraw/excalidraw/data/restore";
|
|
||||||
import type {
|
|
||||||
FileId,
|
|
||||||
NonDeletedExcalidrawElement,
|
|
||||||
OrderedExcalidrawElement,
|
|
||||||
} from "@excalidraw/element/types";
|
|
||||||
import type {
|
|
||||||
AppState,
|
|
||||||
ExcalidrawImperativeAPI,
|
|
||||||
BinaryFiles,
|
|
||||||
ExcalidrawInitialDataState,
|
|
||||||
UIAppState,
|
|
||||||
ExcalidrawProps,
|
|
||||||
} from "@excalidraw/excalidraw/types";
|
|
||||||
import type { ResolutionType } from "@excalidraw/common/utility-types";
|
|
||||||
import type { ResolvablePromise } from "@excalidraw/common/utils";
|
|
||||||
|
|
||||||
import CustomStats from "./CustomStats";
|
|
||||||
import {
|
|
||||||
Provider,
|
|
||||||
useAtom,
|
|
||||||
useAtomValue,
|
|
||||||
useAtomWithInitialValue,
|
|
||||||
appJotaiStore,
|
|
||||||
} from "./app-jotai";
|
|
||||||
import {
|
|
||||||
FIREBASE_STORAGE_PREFIXES,
|
|
||||||
isExcalidrawPlusSignedUser,
|
|
||||||
STORAGE_KEYS,
|
|
||||||
SYNC_BROWSER_TABS_TIMEOUT,
|
|
||||||
} from "./app_constants";
|
|
||||||
import Collab, {
|
|
||||||
collabAPIAtom,
|
|
||||||
isCollaboratingAtom,
|
|
||||||
isOfflineAtom,
|
|
||||||
} from "./collab/Collab";
|
|
||||||
import { AppFooter } from "./components/AppFooter";
|
|
||||||
import { AppMainMenu } from "./components/AppMainMenu";
|
|
||||||
import { AppWelcomeScreen } from "./components/AppWelcomeScreen";
|
|
||||||
import {
|
|
||||||
ExportToExcalidrawPlus,
|
|
||||||
exportToExcalidrawPlus,
|
|
||||||
} from "./components/ExportToExcalidrawPlus";
|
|
||||||
import { TopErrorBoundary } from "./components/TopErrorBoundary";
|
|
||||||
|
|
||||||
import {
|
|
||||||
exportToBackend,
|
|
||||||
getCollaborationLinkData,
|
|
||||||
importFromBackend,
|
|
||||||
isCollaborationLink,
|
|
||||||
} from "./data";
|
|
||||||
|
|
||||||
import { updateStaleImageStatuses } from "./data/FileManager";
|
|
||||||
import { FileStatusStore } from "./data/fileStatusStore";
|
|
||||||
import {
|
|
||||||
importFromLocalStorage,
|
|
||||||
importUsernameFromLocalStorage,
|
|
||||||
} from "./data/localStorage";
|
|
||||||
|
|
||||||
import { loadFilesFromFirebase } from "./data/firebase";
|
|
||||||
import {
|
|
||||||
LibraryIndexedDBAdapter,
|
|
||||||
LibraryLocalStorageMigrationAdapter,
|
|
||||||
LocalData,
|
|
||||||
localStorageQuotaExceededAtom,
|
|
||||||
} from "./data/LocalData";
|
|
||||||
import { isBrowserStorageStateNewer } from "./data/tabSync";
|
|
||||||
import { ShareDialog, shareDialogStateAtom } from "./share/ShareDialog";
|
|
||||||
import CollabError, { collabErrorIndicatorAtom } from "./collab/CollabError";
|
|
||||||
import { useHandleAppTheme } from "./useHandleAppTheme";
|
import { useHandleAppTheme } from "./useHandleAppTheme";
|
||||||
import { getPreferredLanguage } from "./app-language/language-detector";
|
import { getPreferredLanguage } from "./app-language/language-detector";
|
||||||
import { useAppLangCode } from "./app-language/language-state";
|
import { useAppLangCode } from "./app-language/language-state";
|
||||||
@@ -142,13 +131,7 @@ import DebugCanvas, {
|
|||||||
} from "./components/DebugCanvas";
|
} from "./components/DebugCanvas";
|
||||||
import { AIComponents } from "./components/AI";
|
import { AIComponents } from "./components/AI";
|
||||||
import { ExcalidrawPlusIframeExport } from "./ExcalidrawPlusIframeExport";
|
import { ExcalidrawPlusIframeExport } from "./ExcalidrawPlusIframeExport";
|
||||||
|
import { isElementLink } from "@excalidraw/excalidraw/element/elementLink";
|
||||||
import "./index.scss";
|
|
||||||
|
|
||||||
import { ExcalidrawPlusPromoBanner } from "./components/ExcalidrawPlusPromoBanner";
|
|
||||||
import { AppSidebar } from "./components/AppSidebar";
|
|
||||||
|
|
||||||
import type { CollabAPI } from "./collab/Collab";
|
|
||||||
|
|
||||||
polyfill();
|
polyfill();
|
||||||
|
|
||||||
@@ -231,20 +214,9 @@ const initializeScene = async (opts: {
|
|||||||
|
|
||||||
const localDataState = importFromLocalStorage();
|
const localDataState = importFromLocalStorage();
|
||||||
|
|
||||||
let scene: Omit<
|
let scene: RestoredDataState & {
|
||||||
RestoredDataState,
|
|
||||||
// we're not storing files in the scene database/localStorage, and instead
|
|
||||||
// fetch them async from a different store
|
|
||||||
"files"
|
|
||||||
> & {
|
|
||||||
scrollToContent?: boolean;
|
scrollToContent?: boolean;
|
||||||
} = {
|
} = await loadScene(null, null, localDataState);
|
||||||
elements: restoreElements(localDataState?.elements, null, {
|
|
||||||
repairBindings: true,
|
|
||||||
deleteInvisibleElements: true,
|
|
||||||
}),
|
|
||||||
appState: restoreAppState(localDataState?.appState, null),
|
|
||||||
};
|
|
||||||
|
|
||||||
let roomLinkData = getCollaborationLinkData(window.location.href);
|
let roomLinkData = getCollaborationLinkData(window.location.href);
|
||||||
const isExternalScene = !!(id || jsonBackendMatch || roomLinkData);
|
const isExternalScene = !!(id || jsonBackendMatch || roomLinkData);
|
||||||
@@ -258,26 +230,11 @@ const initializeScene = async (opts: {
|
|||||||
(await openConfirmModal(shareableLinkConfirmDialog))
|
(await openConfirmModal(shareableLinkConfirmDialog))
|
||||||
) {
|
) {
|
||||||
if (jsonBackendMatch) {
|
if (jsonBackendMatch) {
|
||||||
const imported = await importFromBackend(
|
scene = await loadScene(
|
||||||
jsonBackendMatch[1],
|
jsonBackendMatch[1],
|
||||||
jsonBackendMatch[2],
|
jsonBackendMatch[2],
|
||||||
|
localDataState,
|
||||||
);
|
);
|
||||||
|
|
||||||
scene = {
|
|
||||||
elements: bumpElementVersions(
|
|
||||||
restoreElements(imported.elements, null, {
|
|
||||||
repairBindings: true,
|
|
||||||
deleteInvisibleElements: true,
|
|
||||||
}),
|
|
||||||
localDataState?.elements,
|
|
||||||
),
|
|
||||||
appState: restoreAppState(
|
|
||||||
imported.appState,
|
|
||||||
// local appState when importing from backend to ensure we restore
|
|
||||||
// localStorage user settings which we do not persist on server.
|
|
||||||
localDataState?.appState,
|
|
||||||
),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
scene.scrollToContent = true;
|
scene.scrollToContent = true;
|
||||||
if (!roomLinkData) {
|
if (!roomLinkData) {
|
||||||
@@ -372,8 +329,6 @@ const initializeScene = async (opts: {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ExcalidrawWrapper = () => {
|
const ExcalidrawWrapper = () => {
|
||||||
const excalidrawAPI = useExcalidrawAPI();
|
|
||||||
|
|
||||||
const [errorMessage, setErrorMessage] = useState("");
|
const [errorMessage, setErrorMessage] = useState("");
|
||||||
const isCollabDisabled = isRunningInIframe();
|
const isCollabDisabled = isRunningInIframe();
|
||||||
|
|
||||||
@@ -381,8 +336,6 @@ const ExcalidrawWrapper = () => {
|
|||||||
|
|
||||||
const [langCode, setLangCode] = useAppLangCode();
|
const [langCode, setLangCode] = useAppLangCode();
|
||||||
|
|
||||||
const editorInterface = useEditorInterface();
|
|
||||||
|
|
||||||
// initial state
|
// initial state
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -404,6 +357,9 @@ const ExcalidrawWrapper = () => {
|
|||||||
}, VERSION_TIMEOUT);
|
}, VERSION_TIMEOUT);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const [excalidrawAPI, excalidrawRefCallback] =
|
||||||
|
useCallbackRefState<ExcalidrawImperativeAPI>();
|
||||||
|
|
||||||
const [, setShareDialogState] = useAtom(shareDialogStateAtom);
|
const [, setShareDialogState] = useAtom(shareDialogStateAtom);
|
||||||
const [collabAPI] = useAtom(collabAPIAtom);
|
const [collabAPI] = useAtom(collabAPIAtom);
|
||||||
const [isCollaborating] = useAtomWithInitialValue(isCollaboratingAtom, () => {
|
const [isCollaborating] = useAtomWithInitialValue(isCollaboratingAtom, () => {
|
||||||
@@ -421,7 +377,7 @@ const ExcalidrawWrapper = () => {
|
|||||||
const [, forceRefresh] = useState(false);
|
const [, forceRefresh] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isDevEnv()) {
|
if (import.meta.env.DEV) {
|
||||||
const debugState = loadSavedDebugState();
|
const debugState = loadSavedDebugState();
|
||||||
|
|
||||||
if (debugState.enabled && !window.visualDebug) {
|
if (debugState.enabled && !window.visualDebug) {
|
||||||
@@ -435,15 +391,18 @@ const ExcalidrawWrapper = () => {
|
|||||||
}
|
}
|
||||||
}, [excalidrawAPI]);
|
}, [excalidrawAPI]);
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
useEffect(() => {
|
||||||
// Hoisted loadImages
|
if (!excalidrawAPI || (!isCollabDisabled && !collabAPI)) {
|
||||||
// ---------------------------------------------------------------------------
|
return;
|
||||||
const loadImages = useCallback(
|
}
|
||||||
(data: ResolutionType<typeof initializeScene>, isInitialLoad = false) => {
|
|
||||||
if (!data.scene || !excalidrawAPI) {
|
const loadImages = (
|
||||||
|
data: ResolutionType<typeof initializeScene>,
|
||||||
|
isInitialLoad = false,
|
||||||
|
) => {
|
||||||
|
if (!data.scene) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collabAPI?.isCollaborating()) {
|
if (collabAPI?.isCollaborating()) {
|
||||||
if (data.scene.elements) {
|
if (data.scene.elements) {
|
||||||
collabAPI
|
collabAPI
|
||||||
@@ -470,12 +429,6 @@ const ExcalidrawWrapper = () => {
|
|||||||
}, [] as FileId[]) || [];
|
}, [] as FileId[]) || [];
|
||||||
|
|
||||||
if (data.isExternalScene) {
|
if (data.isExternalScene) {
|
||||||
if (fileIds.length) {
|
|
||||||
// Direct Firebase call (not through FileManager), so track manually
|
|
||||||
FileStatusStore.updateStatuses(
|
|
||||||
fileIds.map((id) => [id, "loading"]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
loadFilesFromFirebase(
|
loadFilesFromFirebase(
|
||||||
`${FIREBASE_STORAGE_PREFIXES.shareLinkFiles}/${data.id}`,
|
`${FIREBASE_STORAGE_PREFIXES.shareLinkFiles}/${data.id}`,
|
||||||
data.key,
|
data.key,
|
||||||
@@ -487,18 +440,12 @@ const ExcalidrawWrapper = () => {
|
|||||||
erroredFiles,
|
erroredFiles,
|
||||||
elements: excalidrawAPI.getSceneElementsIncludingDeleted(),
|
elements: excalidrawAPI.getSceneElementsIncludingDeleted(),
|
||||||
});
|
});
|
||||||
FileStatusStore.updateStatuses([
|
|
||||||
...loadedFiles.map((f) => [f.id, "loaded"] as [FileId, "loaded"]),
|
|
||||||
...[...erroredFiles.keys()].map(
|
|
||||||
(id) => [id, "error"] as [FileId, "error"],
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
});
|
});
|
||||||
} else if (isInitialLoad) {
|
} else if (isInitialLoad) {
|
||||||
if (fileIds.length) {
|
if (fileIds.length) {
|
||||||
LocalData.fileStorage
|
LocalData.fileStorage
|
||||||
.getFiles(fileIds)
|
.getFiles(fileIds)
|
||||||
.then(async ({ loadedFiles, erroredFiles }) => {
|
.then(({ loadedFiles, erroredFiles }) => {
|
||||||
if (loadedFiles.length) {
|
if (loadedFiles.length) {
|
||||||
excalidrawAPI.addFiles(loadedFiles);
|
excalidrawAPI.addFiles(loadedFiles);
|
||||||
}
|
}
|
||||||
@@ -511,19 +458,10 @@ const ExcalidrawWrapper = () => {
|
|||||||
}
|
}
|
||||||
// on fresh load, clear unused files from IDB (from previous
|
// on fresh load, clear unused files from IDB (from previous
|
||||||
// session)
|
// session)
|
||||||
LocalData.fileStorage.clearObsoleteFiles({
|
LocalData.fileStorage.clearObsoleteFiles({ currentFileIds: fileIds });
|
||||||
currentFileIds: fileIds,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
[collabAPI, excalidrawAPI],
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!excalidrawAPI || (!isCollabDisabled && !collabAPI)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
initializeScene({ collabAPI, excalidrawAPI }).then(async (data) => {
|
initializeScene({ collabAPI, excalidrawAPI }).then(async (data) => {
|
||||||
loadImages(data, /* isInitialLoad */ true);
|
loadImages(data, /* isInitialLoad */ true);
|
||||||
@@ -546,10 +484,8 @@ const ExcalidrawWrapper = () => {
|
|||||||
loadImages(data);
|
loadImages(data);
|
||||||
if (data.scene) {
|
if (data.scene) {
|
||||||
excalidrawAPI.updateScene({
|
excalidrawAPI.updateScene({
|
||||||
elements: restoreElements(data.scene.elements, null, {
|
...data.scene,
|
||||||
repairBindings: true,
|
...restore(data.scene, null, null, { repairBindings: true }),
|
||||||
}),
|
|
||||||
appState: restoreAppState(data.scene.appState, null),
|
|
||||||
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
|
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -557,6 +493,11 @@ const ExcalidrawWrapper = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const titleTimeout = setTimeout(
|
||||||
|
() => (document.title = APP_NAME),
|
||||||
|
TITLE_TIMEOUT,
|
||||||
|
);
|
||||||
|
|
||||||
const syncData = debounce(() => {
|
const syncData = debounce(() => {
|
||||||
if (isTestEnv()) {
|
if (isTestEnv()) {
|
||||||
return;
|
return;
|
||||||
@@ -647,8 +588,9 @@ const ExcalidrawWrapper = () => {
|
|||||||
visibilityChange,
|
visibilityChange,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
clearTimeout(titleTimeout);
|
||||||
};
|
};
|
||||||
}, [isCollabDisabled, collabAPI, excalidrawAPI, setLangCode, loadImages]);
|
}, [isCollabDisabled, collabAPI, excalidrawAPI, setLangCode]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unloadHandler = (event: BeforeUnloadEvent) => {
|
const unloadHandler = (event: BeforeUnloadEvent) => {
|
||||||
@@ -660,13 +602,7 @@ const ExcalidrawWrapper = () => {
|
|||||||
excalidrawAPI.getSceneElements(),
|
excalidrawAPI.getSceneElements(),
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
if (import.meta.env.VITE_APP_DISABLE_PREVENT_UNLOAD !== "true") {
|
preventUnload(event);
|
||||||
preventUnload(event);
|
|
||||||
} else {
|
|
||||||
console.warn(
|
|
||||||
"preventing unload disabled (VITE_APP_DISABLE_PREVENT_UNLOAD)",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.addEventListener(EVENT.BEFORE_UNLOAD, unloadHandler);
|
window.addEventListener(EVENT.BEFORE_UNLOAD, unloadHandler);
|
||||||
@@ -721,8 +657,8 @@ const ExcalidrawWrapper = () => {
|
|||||||
debugRenderer(
|
debugRenderer(
|
||||||
debugCanvasRef.current,
|
debugCanvasRef.current,
|
||||||
appState,
|
appState,
|
||||||
elements,
|
|
||||||
window.devicePixelRatio,
|
window.devicePixelRatio,
|
||||||
|
() => forceRefresh((prev) => !prev),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -786,63 +722,11 @@ const ExcalidrawWrapper = () => {
|
|||||||
|
|
||||||
const isOffline = useAtomValue(isOfflineAtom);
|
const isOffline = useAtomValue(isOfflineAtom);
|
||||||
|
|
||||||
const localStorageQuotaExceeded = useAtomValue(localStorageQuotaExceededAtom);
|
|
||||||
|
|
||||||
const onCollabDialogOpen = useCallback(
|
const onCollabDialogOpen = useCallback(
|
||||||
() => setShareDialogState({ isOpen: true, type: "collaborationOnly" }),
|
() => setShareDialogState({ isOpen: true, type: "collaborationOnly" }),
|
||||||
[setShareDialogState],
|
[setShareDialogState],
|
||||||
);
|
);
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// onExport — intercepts file save to wait for pending image loads
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
const onExport: Required<ExcalidrawProps>["onExport"] = useCallback(
|
|
||||||
async function* () {
|
|
||||||
let snapshot = FileStatusStore.getSnapshot();
|
|
||||||
const { pending, total } = FileStatusStore.getPendingCount(
|
|
||||||
snapshot.value,
|
|
||||||
);
|
|
||||||
if (pending === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Yield initial progress
|
|
||||||
yield {
|
|
||||||
type: "progress",
|
|
||||||
progress: (total - pending) / total,
|
|
||||||
message: `Loading images (${total - pending}/${total})...`,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Wait for all pending images to finish
|
|
||||||
while (true) {
|
|
||||||
snapshot = await FileStatusStore.pull(snapshot.version);
|
|
||||||
const { pending: nowPending, total: nowTotal } =
|
|
||||||
FileStatusStore.getPendingCount(snapshot.value);
|
|
||||||
|
|
||||||
yield {
|
|
||||||
type: "progress",
|
|
||||||
progress: (nowTotal - nowPending) / nowTotal,
|
|
||||||
message: `Loading images (${nowTotal - nowPending}/${nowTotal})...`,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (nowPending === 0) {
|
|
||||||
await new Promise((r) => setTimeout(r, 500));
|
|
||||||
yield {
|
|
||||||
type: "progress",
|
|
||||||
message: `Preparing export...`,
|
|
||||||
};
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
// const onExport = () => {
|
|
||||||
// return new Promise((r) => setTimeout(r, 2500));
|
|
||||||
// // console.log("onExport");
|
|
||||||
// };
|
|
||||||
|
|
||||||
// browsers generally prevent infinite self-embedding, there are
|
// browsers generally prevent infinite self-embedding, there are
|
||||||
// cases where it still happens, and while we disallow self-embedding
|
// cases where it still happens, and while we disallow self-embedding
|
||||||
// by not whitelisting our own origin, this serves as an additional guard
|
// by not whitelisting our own origin, this serves as an additional guard
|
||||||
@@ -909,8 +793,8 @@ const ExcalidrawWrapper = () => {
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Excalidraw
|
<Excalidraw
|
||||||
|
excalidrawAPI={excalidrawRefCallback}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
onExport={onExport}
|
|
||||||
initialData={initialStatePromiseRef.current.promise}
|
initialData={initialStatePromiseRef.current.promise}
|
||||||
isCollaborating={isCollaborating}
|
isCollaborating={isCollaborating}
|
||||||
onPointerUpdate={collabAPI?.onPointerUpdate}
|
onPointerUpdate={collabAPI?.onPointerUpdate}
|
||||||
@@ -956,22 +840,14 @@ const ExcalidrawWrapper = () => {
|
|||||||
if (isMobile || !collabAPI || isCollabDisabled) {
|
if (isMobile || !collabAPI || isCollabDisabled) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="excalidraw-ui-top-right">
|
<div className="top-right-ui">
|
||||||
{excalidrawAPI?.getEditorInterface().formFactor === "desktop" && (
|
|
||||||
<ExcalidrawPlusPromoBanner
|
|
||||||
isSignedIn={isExcalidrawPlusSignedUser}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{collabError.message && <CollabError collabError={collabError} />}
|
{collabError.message && <CollabError collabError={collabError} />}
|
||||||
<LiveCollaborationTrigger
|
<LiveCollaborationTrigger
|
||||||
isCollaborating={isCollaborating}
|
isCollaborating={isCollaborating}
|
||||||
onSelect={() =>
|
onSelect={() =>
|
||||||
setShareDialogState({ isOpen: true, type: "share" })
|
setShareDialogState({ isOpen: true, type: "share" })
|
||||||
}
|
}
|
||||||
editorInterface={editorInterface}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -1020,15 +896,10 @@ const ExcalidrawWrapper = () => {
|
|||||||
|
|
||||||
<TTDDialogTrigger />
|
<TTDDialogTrigger />
|
||||||
{isCollaborating && isOffline && (
|
{isCollaborating && isOffline && (
|
||||||
<div className="alertalert--warning">
|
<div className="collab-offline-warning">
|
||||||
{t("alerts.collabOfflineWarning")}
|
{t("alerts.collabOfflineWarning")}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{localStorageQuotaExceeded && (
|
|
||||||
<div className="alert alert--danger">
|
|
||||||
{t("alerts.localStorageQuotaExceeded")}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{latestShareableLink && (
|
{latestShareableLink && (
|
||||||
<ShareableLinkDialog
|
<ShareableLinkDialog
|
||||||
link={latestShareableLink}
|
link={latestShareableLink}
|
||||||
@@ -1057,8 +928,6 @@ const ExcalidrawWrapper = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<AppSidebar />
|
|
||||||
|
|
||||||
{errorMessage && (
|
{errorMessage && (
|
||||||
<ErrorDialog onClose={() => setErrorMessage("")}>
|
<ErrorDialog onClose={() => setErrorMessage("")}>
|
||||||
{errorMessage}
|
{errorMessage}
|
||||||
@@ -1276,9 +1145,7 @@ const ExcalidrawApp = () => {
|
|||||||
return (
|
return (
|
||||||
<TopErrorBoundary>
|
<TopErrorBoundary>
|
||||||
<Provider store={appJotaiStore}>
|
<Provider store={appJotaiStore}>
|
||||||
<ExcalidrawAPIProvider>
|
<ExcalidrawWrapper />
|
||||||
<ExcalidrawWrapper />
|
|
||||||
</ExcalidrawAPIProvider>
|
|
||||||
</Provider>
|
</Provider>
|
||||||
</TopErrorBoundary>
|
</TopErrorBoundary>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,21 +1,15 @@
|
|||||||
import { Stats } from "@excalidraw/excalidraw";
|
|
||||||
import { copyTextToSystemClipboard } from "@excalidraw/excalidraw/clipboard";
|
|
||||||
import {
|
|
||||||
DEFAULT_VERSION,
|
|
||||||
debounce,
|
|
||||||
getVersion,
|
|
||||||
nFormatter,
|
|
||||||
} from "@excalidraw/common";
|
|
||||||
import { t } from "@excalidraw/excalidraw/i18n";
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
import { debounce, getVersion, nFormatter } from "@excalidraw/excalidraw/utils";
|
||||||
import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types";
|
|
||||||
import type { UIAppState } from "@excalidraw/excalidraw/types";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getElementsStorageSize,
|
getElementsStorageSize,
|
||||||
getTotalStorageSize,
|
getTotalStorageSize,
|
||||||
} from "./data/localStorage";
|
} from "./data/localStorage";
|
||||||
|
import { DEFAULT_VERSION } from "@excalidraw/excalidraw/constants";
|
||||||
|
import { t } from "@excalidraw/excalidraw/i18n";
|
||||||
|
import { copyTextToSystemClipboard } from "@excalidraw/excalidraw/clipboard";
|
||||||
|
import type { NonDeletedExcalidrawElement } from "@excalidraw/excalidraw/element/types";
|
||||||
|
import type { UIAppState } from "@excalidraw/excalidraw/types";
|
||||||
|
import { Stats } from "@excalidraw/excalidraw";
|
||||||
|
|
||||||
type StorageSizes = { scene: number; total: number };
|
type StorageSizes = { scene: number; total: number };
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
import { base64urlToString } from "@excalidraw/excalidraw/data/encode";
|
|
||||||
import { ExcalidrawError } from "@excalidraw/excalidraw/errors";
|
|
||||||
import { useLayoutEffect, useRef } from "react";
|
import { useLayoutEffect, useRef } from "react";
|
||||||
|
import { STORAGE_KEYS } from "./app_constants";
|
||||||
|
import { LocalData } from "./data/LocalData";
|
||||||
import type {
|
import type {
|
||||||
FileId,
|
FileId,
|
||||||
OrderedExcalidrawElement,
|
OrderedExcalidrawElement,
|
||||||
} from "@excalidraw/element/types";
|
} from "@excalidraw/excalidraw/element/types";
|
||||||
import type { AppState, BinaryFileData } from "@excalidraw/excalidraw/types";
|
import type { AppState, BinaryFileData } from "@excalidraw/excalidraw/types";
|
||||||
|
import { ExcalidrawError } from "@excalidraw/excalidraw/errors";
|
||||||
import { STORAGE_KEYS } from "./app_constants";
|
import { base64urlToString } from "@excalidraw/excalidraw/data/encode";
|
||||||
import { LocalData } from "./data/LocalData";
|
|
||||||
|
|
||||||
const EVENT_REQUEST_SCENE = "REQUEST_SCENE";
|
const EVENT_REQUEST_SCENE = "REQUEST_SCENE";
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import { useI18n, languages } from "@excalidraw/excalidraw/i18n";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { useI18n, languages } from "@excalidraw/excalidraw/i18n";
|
||||||
import { useSetAtom } from "../app-jotai";
|
import { useSetAtom } from "../app-jotai";
|
||||||
|
|
||||||
import { appLangCodeAtom } from "./language-state";
|
import { appLangCodeAtom } from "./language-state";
|
||||||
|
|
||||||
export const LanguageList = ({ style }: { style?: React.CSSProperties }) => {
|
export const LanguageList = ({ style }: { style?: React.CSSProperties }) => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { defaultLang, languages } from "@excalidraw/excalidraw";
|
|
||||||
import LanguageDetector from "i18next-browser-languagedetector";
|
import LanguageDetector from "i18next-browser-languagedetector";
|
||||||
|
import { defaultLang, languages } from "@excalidraw/excalidraw";
|
||||||
|
|
||||||
export const languageDetector = new LanguageDetector();
|
export const languageDetector = new LanguageDetector();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
|
||||||
import { atom, useAtom } from "../app-jotai";
|
import { atom, useAtom } from "../app-jotai";
|
||||||
|
|
||||||
import { getPreferredLanguage, languageDetector } from "./language-detector";
|
import { getPreferredLanguage, languageDetector } from "./language-detector";
|
||||||
|
|
||||||
export const appLangCodeAtom = atom(getPreferredLanguage());
|
export const appLangCodeAtom = atom(getPreferredLanguage());
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ export const SYNC_BROWSER_TABS_TIMEOUT = 50;
|
|||||||
export const CURSOR_SYNC_TIMEOUT = 33; // ~30fps
|
export const CURSOR_SYNC_TIMEOUT = 33; // ~30fps
|
||||||
export const DELETED_ELEMENT_TIMEOUT = 24 * 60 * 60 * 1000; // 1 day
|
export const DELETED_ELEMENT_TIMEOUT = 24 * 60 * 60 * 1000; // 1 day
|
||||||
|
|
||||||
// should be aligned with MAX_ALLOWED_FILE_BYTES
|
export const FILE_UPLOAD_MAX_BYTES = 3 * 1024 * 1024; // 3 MiB
|
||||||
export const FILE_UPLOAD_MAX_BYTES = 4 * 1024 * 1024; // 4 MiB
|
|
||||||
// 1 year (https://stackoverflow.com/a/25201898/927631)
|
// 1 year (https://stackoverflow.com/a/25201898/927631)
|
||||||
export const FILE_CACHE_MAX_AGE_SEC = 31536000;
|
export const FILE_CACHE_MAX_AGE_SEC = 31536000;
|
||||||
|
|
||||||
@@ -46,7 +45,6 @@ export const STORAGE_KEYS = {
|
|||||||
VERSION_FILES: "version-files",
|
VERSION_FILES: "version-files",
|
||||||
|
|
||||||
IDB_LIBRARY: "excalidraw-library",
|
IDB_LIBRARY: "excalidraw-library",
|
||||||
IDB_TTD_CHATS: "excalidraw-ttd-chats",
|
|
||||||
|
|
||||||
// do not use apart from migrations
|
// do not use apart from migrations
|
||||||
__LEGACY_LOCAL_STORAGE_LIBRARY: "excalidraw-library",
|
__LEGACY_LOCAL_STORAGE_LIBRARY: "excalidraw-library",
|
||||||
|
|||||||
@@ -1,47 +1,5 @@
|
|||||||
import {
|
|
||||||
CaptureUpdateAction,
|
|
||||||
getSceneVersion,
|
|
||||||
restoreElements,
|
|
||||||
zoomToFitBounds,
|
|
||||||
reconcileElements,
|
|
||||||
} from "@excalidraw/excalidraw";
|
|
||||||
import { ErrorDialog } from "@excalidraw/excalidraw/components/ErrorDialog";
|
|
||||||
import { APP_NAME, cloneJSON, EVENT, toBrandedType } from "@excalidraw/common";
|
|
||||||
import {
|
|
||||||
IDLE_THRESHOLD,
|
|
||||||
ACTIVE_THRESHOLD,
|
|
||||||
UserIdleState,
|
|
||||||
assertNever,
|
|
||||||
isDevEnv,
|
|
||||||
isTestEnv,
|
|
||||||
preventUnload,
|
|
||||||
resolvablePromise,
|
|
||||||
throttleRAF,
|
|
||||||
} from "@excalidraw/common";
|
|
||||||
import { decryptData } from "@excalidraw/excalidraw/data/encryption";
|
|
||||||
import { getVisibleSceneBounds } from "@excalidraw/element";
|
|
||||||
import { newElementWith } from "@excalidraw/element";
|
|
||||||
import { isImageElement, isInitializedImageElement } from "@excalidraw/element";
|
|
||||||
import { AbortError } from "@excalidraw/excalidraw/errors";
|
|
||||||
import { t } from "@excalidraw/excalidraw/i18n";
|
|
||||||
import { withBatchedUpdates } from "@excalidraw/excalidraw/reactUtils";
|
|
||||||
|
|
||||||
import throttle from "lodash.throttle";
|
import throttle from "lodash.throttle";
|
||||||
import { PureComponent } from "react";
|
import { PureComponent } from "react";
|
||||||
|
|
||||||
import { bumpElementVersions } from "@excalidraw/excalidraw/data/restore";
|
|
||||||
|
|
||||||
import type {
|
|
||||||
ReconciledExcalidrawElement,
|
|
||||||
RemoteExcalidrawElement,
|
|
||||||
} from "@excalidraw/excalidraw/data/reconcile";
|
|
||||||
import type { ImportedDataState } from "@excalidraw/excalidraw/data/types";
|
|
||||||
import type {
|
|
||||||
ExcalidrawElement,
|
|
||||||
FileId,
|
|
||||||
InitializedExcalidrawImageElement,
|
|
||||||
OrderedExcalidrawElement,
|
|
||||||
} from "@excalidraw/element/types";
|
|
||||||
import type {
|
import type {
|
||||||
BinaryFileData,
|
BinaryFileData,
|
||||||
ExcalidrawImperativeAPI,
|
ExcalidrawImperativeAPI,
|
||||||
@@ -49,9 +7,28 @@ import type {
|
|||||||
Collaborator,
|
Collaborator,
|
||||||
Gesture,
|
Gesture,
|
||||||
} from "@excalidraw/excalidraw/types";
|
} from "@excalidraw/excalidraw/types";
|
||||||
import type { Mutable, ValueOf } from "@excalidraw/common/utility-types";
|
import { ErrorDialog } from "@excalidraw/excalidraw/components/ErrorDialog";
|
||||||
|
import { APP_NAME, ENV, EVENT } from "@excalidraw/excalidraw/constants";
|
||||||
import { appJotaiStore, atom } from "../app-jotai";
|
import type { ImportedDataState } from "@excalidraw/excalidraw/data/types";
|
||||||
|
import type {
|
||||||
|
ExcalidrawElement,
|
||||||
|
FileId,
|
||||||
|
InitializedExcalidrawImageElement,
|
||||||
|
OrderedExcalidrawElement,
|
||||||
|
} from "@excalidraw/excalidraw/element/types";
|
||||||
|
import {
|
||||||
|
CaptureUpdateAction,
|
||||||
|
getSceneVersion,
|
||||||
|
restoreElements,
|
||||||
|
zoomToFitBounds,
|
||||||
|
reconcileElements,
|
||||||
|
} from "@excalidraw/excalidraw";
|
||||||
|
import {
|
||||||
|
assertNever,
|
||||||
|
preventUnload,
|
||||||
|
resolvablePromise,
|
||||||
|
throttleRAF,
|
||||||
|
} from "@excalidraw/excalidraw/utils";
|
||||||
import {
|
import {
|
||||||
CURSOR_SYNC_TIMEOUT,
|
CURSOR_SYNC_TIMEOUT,
|
||||||
FILE_UPLOAD_MAX_BYTES,
|
FILE_UPLOAD_MAX_BYTES,
|
||||||
@@ -62,18 +39,15 @@ import {
|
|||||||
SYNC_FULL_SCENE_INTERVAL_MS,
|
SYNC_FULL_SCENE_INTERVAL_MS,
|
||||||
WS_EVENTS,
|
WS_EVENTS,
|
||||||
} from "../app_constants";
|
} from "../app_constants";
|
||||||
|
import type {
|
||||||
|
SocketUpdateDataSource,
|
||||||
|
SyncableExcalidrawElement,
|
||||||
|
} from "../data";
|
||||||
import {
|
import {
|
||||||
generateCollaborationLinkData,
|
generateCollaborationLinkData,
|
||||||
getCollaborationLink,
|
getCollaborationLink,
|
||||||
getSyncableElements,
|
getSyncableElements,
|
||||||
} from "../data";
|
} from "../data";
|
||||||
import {
|
|
||||||
encodeFilesForUpload,
|
|
||||||
FileManager,
|
|
||||||
updateStaleImageStatuses,
|
|
||||||
} from "../data/FileManager";
|
|
||||||
import { FileStatusStore } from "../data/fileStatusStore";
|
|
||||||
import { LocalData } from "../data/LocalData";
|
|
||||||
import {
|
import {
|
||||||
isSavedToFirebase,
|
isSavedToFirebase,
|
||||||
loadFilesFromFirebase,
|
loadFilesFromFirebase,
|
||||||
@@ -85,15 +59,36 @@ import {
|
|||||||
importUsernameFromLocalStorage,
|
importUsernameFromLocalStorage,
|
||||||
saveUsernameToLocalStorage,
|
saveUsernameToLocalStorage,
|
||||||
} from "../data/localStorage";
|
} from "../data/localStorage";
|
||||||
import { resetBrowserStateVersions } from "../data/tabSync";
|
|
||||||
|
|
||||||
import { collabErrorIndicatorAtom } from "./CollabError";
|
|
||||||
import Portal from "./Portal";
|
import Portal from "./Portal";
|
||||||
|
import { t } from "@excalidraw/excalidraw/i18n";
|
||||||
|
import {
|
||||||
|
IDLE_THRESHOLD,
|
||||||
|
ACTIVE_THRESHOLD,
|
||||||
|
UserIdleState,
|
||||||
|
} from "@excalidraw/excalidraw/constants";
|
||||||
|
import {
|
||||||
|
encodeFilesForUpload,
|
||||||
|
FileManager,
|
||||||
|
updateStaleImageStatuses,
|
||||||
|
} from "../data/FileManager";
|
||||||
|
import { AbortError } from "@excalidraw/excalidraw/errors";
|
||||||
|
import {
|
||||||
|
isImageElement,
|
||||||
|
isInitializedImageElement,
|
||||||
|
} from "@excalidraw/excalidraw/element/typeChecks";
|
||||||
|
import { newElementWith } from "@excalidraw/excalidraw/element/mutateElement";
|
||||||
|
import { decryptData } from "@excalidraw/excalidraw/data/encryption";
|
||||||
|
import { resetBrowserStateVersions } from "../data/tabSync";
|
||||||
|
import { LocalData } from "../data/LocalData";
|
||||||
|
import { appJotaiStore, atom } from "../app-jotai";
|
||||||
|
import type { Mutable, ValueOf } from "@excalidraw/excalidraw/utility-types";
|
||||||
|
import { getVisibleSceneBounds } from "@excalidraw/excalidraw/element/bounds";
|
||||||
|
import { withBatchedUpdates } from "@excalidraw/excalidraw/reactUtils";
|
||||||
|
import { collabErrorIndicatorAtom } from "./CollabError";
|
||||||
import type {
|
import type {
|
||||||
SocketUpdateDataSource,
|
ReconciledExcalidrawElement,
|
||||||
SyncableExcalidrawElement,
|
RemoteExcalidrawElement,
|
||||||
} from "../data";
|
} from "@excalidraw/excalidraw/data/reconcile";
|
||||||
|
|
||||||
export const collabAPIAtom = atom<CollabAPI | null>(null);
|
export const collabAPIAtom = atom<CollabAPI | null>(null);
|
||||||
export const isCollaboratingAtom = atom(false);
|
export const isCollaboratingAtom = atom(false);
|
||||||
@@ -150,7 +145,6 @@ class Collab extends PureComponent<CollabProps, CollabState> {
|
|||||||
};
|
};
|
||||||
this.portal = new Portal(this);
|
this.portal = new Portal(this);
|
||||||
this.fileManager = new FileManager({
|
this.fileManager = new FileManager({
|
||||||
onFileStatusChange: FileStatusStore.updateStatuses.bind(FileStatusStore),
|
|
||||||
getFiles: async (fileIds) => {
|
getFiles: async (fileIds) => {
|
||||||
const { roomId, roomKey } = this.portal;
|
const { roomId, roomKey } = this.portal;
|
||||||
if (!roomId || !roomKey) {
|
if (!roomId || !roomKey) {
|
||||||
@@ -242,7 +236,7 @@ class Collab extends PureComponent<CollabProps, CollabState> {
|
|||||||
|
|
||||||
appJotaiStore.set(collabAPIAtom, collabAPI);
|
appJotaiStore.set(collabAPIAtom, collabAPI);
|
||||||
|
|
||||||
if (isTestEnv() || isDevEnv()) {
|
if (import.meta.env.MODE === ENV.TEST || import.meta.env.DEV) {
|
||||||
window.collab = window.collab || ({} as Window["collab"]);
|
window.collab = window.collab || ({} as Window["collab"]);
|
||||||
Object.defineProperties(window, {
|
Object.defineProperties(window, {
|
||||||
collab: {
|
collab: {
|
||||||
@@ -302,20 +296,13 @@ class Collab extends PureComponent<CollabProps, CollabState> {
|
|||||||
// the purpose is to run in immediately after user decides to stay
|
// the purpose is to run in immediately after user decides to stay
|
||||||
this.saveCollabRoomToFirebase(syncableElements);
|
this.saveCollabRoomToFirebase(syncableElements);
|
||||||
|
|
||||||
if (import.meta.env.VITE_APP_DISABLE_PREVENT_UNLOAD !== "true") {
|
preventUnload(event);
|
||||||
preventUnload(event);
|
|
||||||
} else {
|
|
||||||
console.warn(
|
|
||||||
"preventing unload disabled (VITE_APP_DISABLE_PREVENT_UNLOAD)",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
saveCollabRoomToFirebase = async (
|
saveCollabRoomToFirebase = async (
|
||||||
syncableElements: readonly SyncableExcalidrawElement[],
|
syncableElements: readonly SyncableExcalidrawElement[],
|
||||||
) => {
|
) => {
|
||||||
syncableElements = cloneJSON(syncableElements);
|
|
||||||
try {
|
try {
|
||||||
const storedElements = await saveToFirebase(
|
const storedElements = await saveToFirebase(
|
||||||
this.portal,
|
this.portal,
|
||||||
@@ -446,7 +433,7 @@ class Collab extends PureComponent<CollabProps, CollabState> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private decryptPayload = async (
|
private decryptPayload = async (
|
||||||
iv: Uint8Array<ArrayBuffer>,
|
iv: Uint8Array,
|
||||||
encryptedData: ArrayBuffer,
|
encryptedData: ArrayBuffer,
|
||||||
decryptionKey: string,
|
decryptionKey: string,
|
||||||
): Promise<ValueOf<SocketUpdateDataSource>> => {
|
): Promise<ValueOf<SocketUpdateDataSource>> => {
|
||||||
@@ -535,10 +522,7 @@ class Collab extends PureComponent<CollabProps, CollabState> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existingRoomLinkData) {
|
if (!existingRoomLinkData) {
|
||||||
// when joining existing room, don't merge it with current scene data
|
|
||||||
this.excalidrawAPI.resetScene();
|
|
||||||
} else {
|
|
||||||
const elements = this.excalidrawAPI.getSceneElements().map((element) => {
|
const elements = this.excalidrawAPI.getSceneElements().map((element) => {
|
||||||
if (isImageElement(element) && element.status === "saved") {
|
if (isImageElement(element) && element.status === "saved") {
|
||||||
return newElementWith(element, { status: "pending" });
|
return newElementWith(element, { status: "pending" });
|
||||||
@@ -567,7 +551,7 @@ class Collab extends PureComponent<CollabProps, CollabState> {
|
|||||||
// All socket listeners are moving to Portal
|
// All socket listeners are moving to Portal
|
||||||
this.portal.socket.on(
|
this.portal.socket.on(
|
||||||
"client-broadcast",
|
"client-broadcast",
|
||||||
async (encryptedData: ArrayBuffer, iv: Uint8Array<ArrayBuffer>) => {
|
async (encryptedData: ArrayBuffer, iv: Uint8Array) => {
|
||||||
if (!this.portal.roomKey) {
|
if (!this.portal.roomKey) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -584,9 +568,7 @@ class Collab extends PureComponent<CollabProps, CollabState> {
|
|||||||
case WS_SUBTYPES.INIT: {
|
case WS_SUBTYPES.INIT: {
|
||||||
if (!this.portal.socketInitialized) {
|
if (!this.portal.socketInitialized) {
|
||||||
this.initializeRoom({ fetchScene: false });
|
this.initializeRoom({ fetchScene: false });
|
||||||
const remoteElements = toBrandedType<
|
const remoteElements = decryptedData.payload.elements;
|
||||||
readonly RemoteExcalidrawElement[]
|
|
||||||
>(decryptedData.payload.elements);
|
|
||||||
const reconciledElements =
|
const reconciledElements =
|
||||||
this._reconcileElements(remoteElements);
|
this._reconcileElements(remoteElements);
|
||||||
this.handleRemoteSceneUpdate(reconciledElements);
|
this.handleRemoteSceneUpdate(reconciledElements);
|
||||||
@@ -600,11 +582,7 @@ class Collab extends PureComponent<CollabProps, CollabState> {
|
|||||||
}
|
}
|
||||||
case WS_SUBTYPES.UPDATE:
|
case WS_SUBTYPES.UPDATE:
|
||||||
this.handleRemoteSceneUpdate(
|
this.handleRemoteSceneUpdate(
|
||||||
this._reconcileElements(
|
this._reconcileElements(decryptedData.payload.elements),
|
||||||
toBrandedType<readonly RemoteExcalidrawElement[]>(
|
|
||||||
decryptedData.payload.elements,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case WS_SUBTYPES.MOUSE_LOCATION: {
|
case WS_SUBTYPES.MOUSE_LOCATION: {
|
||||||
@@ -753,28 +731,17 @@ class Collab extends PureComponent<CollabProps, CollabState> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private _reconcileElements = (
|
private _reconcileElements = (
|
||||||
remoteElements: readonly RemoteExcalidrawElement[],
|
remoteElements: readonly ExcalidrawElement[],
|
||||||
): ReconciledExcalidrawElement[] => {
|
): ReconciledExcalidrawElement[] => {
|
||||||
|
const localElements = this.getSceneElementsIncludingDeleted();
|
||||||
const appState = this.excalidrawAPI.getAppState();
|
const appState = this.excalidrawAPI.getAppState();
|
||||||
|
const restoredRemoteElements = restoreElements(remoteElements, null);
|
||||||
const existingElements = this.getSceneElementsIncludingDeleted();
|
const reconciledElements = reconcileElements(
|
||||||
|
localElements,
|
||||||
// NOTE ideally we restore _after_ reconciliation but we can't do that
|
restoredRemoteElements as RemoteExcalidrawElement[],
|
||||||
// as we'd regenerate even elements such as appState.newElement which would
|
|
||||||
// break the state
|
|
||||||
remoteElements = restoreElements(remoteElements, existingElements);
|
|
||||||
|
|
||||||
let reconciledElements = reconcileElements(
|
|
||||||
existingElements,
|
|
||||||
remoteElements,
|
|
||||||
appState,
|
appState,
|
||||||
);
|
);
|
||||||
|
|
||||||
reconciledElements = bumpElementVersions(
|
|
||||||
reconciledElements,
|
|
||||||
existingElements,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Avoid broadcasting to the rest of the collaborators the scene
|
// Avoid broadcasting to the rest of the collaborators the scene
|
||||||
// we just received!
|
// we just received!
|
||||||
// Note: this needs to be set before updating the scene as it
|
// Note: this needs to be set before updating the scene as it
|
||||||
@@ -1042,7 +1009,7 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTestEnv() || isDevEnv()) {
|
if (import.meta.env.MODE === ENV.TEST || import.meta.env.DEV) {
|
||||||
window.collab = window.collab || ({} as Window["collab"]);
|
window.collab = window.collab || ({} as Window["collab"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { Tooltip } from "@excalidraw/excalidraw/components/Tooltip";
|
|||||||
import { warning } from "@excalidraw/excalidraw/components/icons";
|
import { warning } from "@excalidraw/excalidraw/components/icons";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
|
||||||
import { atom } from "../app-jotai";
|
import { atom } from "../app-jotai";
|
||||||
|
|
||||||
import "./CollabError.scss";
|
import "./CollabError.scss";
|
||||||
|
|||||||
@@ -1,26 +1,25 @@
|
|||||||
import { CaptureUpdateAction } from "@excalidraw/excalidraw";
|
|
||||||
import { trackEvent } from "@excalidraw/excalidraw/analytics";
|
|
||||||
import { encryptData } from "@excalidraw/excalidraw/data/encryption";
|
|
||||||
import { newElementWith } from "@excalidraw/element";
|
|
||||||
import throttle from "lodash.throttle";
|
|
||||||
|
|
||||||
import type { UserIdleState } from "@excalidraw/common";
|
|
||||||
import type { OrderedExcalidrawElement } from "@excalidraw/element/types";
|
|
||||||
import type {
|
|
||||||
OnUserFollowedPayload,
|
|
||||||
SocketId,
|
|
||||||
} from "@excalidraw/excalidraw/types";
|
|
||||||
|
|
||||||
import { WS_EVENTS, FILE_UPLOAD_TIMEOUT, WS_SUBTYPES } from "../app_constants";
|
|
||||||
import { isSyncableElement } from "../data";
|
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
SocketUpdateData,
|
SocketUpdateData,
|
||||||
SocketUpdateDataSource,
|
SocketUpdateDataSource,
|
||||||
SyncableExcalidrawElement,
|
SyncableExcalidrawElement,
|
||||||
} from "../data";
|
} from "../data";
|
||||||
|
import { isSyncableElement } from "../data";
|
||||||
|
|
||||||
import type { TCollabClass } from "./Collab";
|
import type { TCollabClass } from "./Collab";
|
||||||
|
|
||||||
|
import type { OrderedExcalidrawElement } from "@excalidraw/excalidraw/element/types";
|
||||||
|
import { WS_EVENTS, FILE_UPLOAD_TIMEOUT, WS_SUBTYPES } from "../app_constants";
|
||||||
|
import type {
|
||||||
|
OnUserFollowedPayload,
|
||||||
|
SocketId,
|
||||||
|
} from "@excalidraw/excalidraw/types";
|
||||||
|
import type { UserIdleState } from "@excalidraw/excalidraw/constants";
|
||||||
|
import { trackEvent } from "@excalidraw/excalidraw/analytics";
|
||||||
|
import throttle from "lodash.throttle";
|
||||||
|
import { newElementWith } from "@excalidraw/excalidraw/element/mutateElement";
|
||||||
|
import { encryptData } from "@excalidraw/excalidraw/data/encryption";
|
||||||
import type { Socket } from "socket.io-client";
|
import type { Socket } from "socket.io-client";
|
||||||
|
import { CaptureUpdateAction } from "@excalidraw/excalidraw";
|
||||||
|
|
||||||
class Portal {
|
class Portal {
|
||||||
collab: TCollabClass;
|
collab: TCollabClass;
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
|
import type { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types";
|
||||||
import {
|
import {
|
||||||
DiagramToCodePlugin,
|
DiagramToCodePlugin,
|
||||||
exportToBlob,
|
exportToBlob,
|
||||||
getTextFromElements,
|
getTextFromElements,
|
||||||
MIME_TYPES,
|
MIME_TYPES,
|
||||||
TTDDialog,
|
TTDDialog,
|
||||||
TTDStreamFetch,
|
|
||||||
} from "@excalidraw/excalidraw";
|
} from "@excalidraw/excalidraw";
|
||||||
import { getDataURL } from "@excalidraw/excalidraw/data/blob";
|
import { getDataURL } from "@excalidraw/excalidraw/data/blob";
|
||||||
import { safelyParseJSON } from "@excalidraw/common";
|
import { safelyParseJSON } from "@excalidraw/excalidraw/utils";
|
||||||
|
|
||||||
import type { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types";
|
|
||||||
|
|
||||||
import { TTDIndexedDBAdapter } from "../data/TTDStorage";
|
|
||||||
|
|
||||||
export const AIComponents = ({
|
export const AIComponents = ({
|
||||||
excalidrawAPI,
|
excalidrawAPI,
|
||||||
@@ -76,7 +72,7 @@ export const AIComponents = ({
|
|||||||
</br>
|
</br>
|
||||||
<div>You can also try <a href="${
|
<div>You can also try <a href="${
|
||||||
import.meta.env.VITE_APP_PLUS_LP
|
import.meta.env.VITE_APP_PLUS_LP
|
||||||
}/plus?utm_source=excalidraw&utm_medium=app&utm_content=d2c" target="_blank" rel="noopener">Excalidraw+</a> to get more requests.</div>
|
}/plus?utm_source=excalidraw&utm_medium=app&utm_content=d2c" target="_blank" rel="noreferrer noopener">Excalidraw+</a> to get more requests.</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>`,
|
</html>`,
|
||||||
@@ -102,23 +98,61 @@ export const AIComponents = ({
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<TTDDialog
|
<TTDDialog
|
||||||
onTextSubmit={async (props) => {
|
onTextSubmit={async (input) => {
|
||||||
const { onChunk, onStreamCreated, signal, messages } = props;
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
`${
|
||||||
|
import.meta.env.VITE_APP_AI_BACKEND
|
||||||
|
}/v1/ai/text-to-diagram/generate`,
|
||||||
|
{
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ prompt: input }),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const result = await TTDStreamFetch({
|
const rateLimit = response.headers.has("X-Ratelimit-Limit")
|
||||||
url: `${
|
? parseInt(response.headers.get("X-Ratelimit-Limit") || "0", 10)
|
||||||
import.meta.env.VITE_APP_AI_BACKEND
|
: undefined;
|
||||||
}/v1/ai/text-to-diagram/chat-streaming`,
|
|
||||||
messages,
|
|
||||||
onChunk,
|
|
||||||
onStreamCreated,
|
|
||||||
extractRateLimits: true,
|
|
||||||
signal,
|
|
||||||
});
|
|
||||||
|
|
||||||
return result;
|
const rateLimitRemaining = response.headers.has(
|
||||||
|
"X-Ratelimit-Remaining",
|
||||||
|
)
|
||||||
|
? parseInt(
|
||||||
|
response.headers.get("X-Ratelimit-Remaining") || "0",
|
||||||
|
10,
|
||||||
|
)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
const json = await response.json();
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
if (response.status === 429) {
|
||||||
|
return {
|
||||||
|
rateLimit,
|
||||||
|
rateLimitRemaining,
|
||||||
|
error: new Error(
|
||||||
|
"Too many requests today, please try again tomorrow!",
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(json.message || "Generation failed...");
|
||||||
|
}
|
||||||
|
|
||||||
|
const generatedResponse = json.generatedResponse;
|
||||||
|
if (!generatedResponse) {
|
||||||
|
throw new Error("Generation failed...");
|
||||||
|
}
|
||||||
|
|
||||||
|
return { generatedResponse, rateLimit, rateLimitRemaining };
|
||||||
|
} catch (err: any) {
|
||||||
|
throw new Error("Request failed");
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
persistenceAdapter={TTDIndexedDBAdapter}
|
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { Footer } from "@excalidraw/excalidraw/index";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { Footer } from "@excalidraw/excalidraw/index";
|
||||||
import { isExcalidrawPlusSignedUser } from "../app_constants";
|
|
||||||
|
|
||||||
import { DebugFooter, isVisualDebuggerEnabled } from "./DebugCanvas";
|
|
||||||
import { EncryptedIcon } from "./EncryptedIcon";
|
import { EncryptedIcon } from "./EncryptedIcon";
|
||||||
|
import { ExcalidrawPlusAppLink } from "./ExcalidrawPlusAppLink";
|
||||||
|
import { isExcalidrawPlusSignedUser } from "../app_constants";
|
||||||
|
import { DebugFooter, isVisualDebuggerEnabled } from "./DebugCanvas";
|
||||||
|
|
||||||
export const AppFooter = React.memo(
|
export const AppFooter = React.memo(
|
||||||
({ onChange }: { onChange: () => void }) => {
|
({ onChange }: { onChange: () => void }) => {
|
||||||
@@ -18,7 +17,11 @@ export const AppFooter = React.memo(
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{isVisualDebuggerEnabled() && <DebugFooter onChange={onChange} />}
|
{isVisualDebuggerEnabled() && <DebugFooter onChange={onChange} />}
|
||||||
{!isExcalidrawPlusSignedUser && <EncryptedIcon />}
|
{isExcalidrawPlusSignedUser ? (
|
||||||
|
<ExcalidrawPlusAppLink />
|
||||||
|
) : (
|
||||||
|
<EncryptedIcon />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Footer>
|
</Footer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
|
import React from "react";
|
||||||
import {
|
import {
|
||||||
loginIcon,
|
loginIcon,
|
||||||
ExcalLogo,
|
ExcalLogo,
|
||||||
eyeIcon,
|
eyeIcon,
|
||||||
} from "@excalidraw/excalidraw/components/icons";
|
} from "@excalidraw/excalidraw/components/icons";
|
||||||
|
import type { Theme } from "@excalidraw/excalidraw/element/types";
|
||||||
import { MainMenu } from "@excalidraw/excalidraw/index";
|
import { MainMenu } from "@excalidraw/excalidraw/index";
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
import { isDevEnv } from "@excalidraw/common";
|
|
||||||
|
|
||||||
import type { Theme } from "@excalidraw/element/types";
|
|
||||||
|
|
||||||
import { LanguageList } from "../app-language/LanguageList";
|
|
||||||
import { isExcalidrawPlusSignedUser } from "../app_constants";
|
import { isExcalidrawPlusSignedUser } from "../app_constants";
|
||||||
|
import { LanguageList } from "../app-language/LanguageList";
|
||||||
import { saveDebugState } from "./DebugCanvas";
|
import { saveDebugState } from "./DebugCanvas";
|
||||||
|
|
||||||
export const AppMainMenu: React.FC<{
|
export const AppMainMenu: React.FC<{
|
||||||
@@ -59,10 +54,10 @@ export const AppMainMenu: React.FC<{
|
|||||||
>
|
>
|
||||||
{isExcalidrawPlusSignedUser ? "Sign in" : "Sign up"}
|
{isExcalidrawPlusSignedUser ? "Sign in" : "Sign up"}
|
||||||
</MainMenu.ItemLink>
|
</MainMenu.ItemLink>
|
||||||
{isDevEnv() && (
|
{import.meta.env.DEV && (
|
||||||
<MainMenu.Item
|
<MainMenu.Item
|
||||||
icon={eyeIcon}
|
icon={eyeIcon}
|
||||||
onSelect={() => {
|
onClick={() => {
|
||||||
if (window.visualDebug) {
|
if (window.visualDebug) {
|
||||||
delete window.visualDebug;
|
delete window.visualDebug;
|
||||||
saveDebugState({ enabled: false });
|
saveDebugState({ enabled: false });
|
||||||
@@ -77,7 +72,6 @@ export const AppMainMenu: React.FC<{
|
|||||||
</MainMenu.Item>
|
</MainMenu.Item>
|
||||||
)}
|
)}
|
||||||
<MainMenu.Separator />
|
<MainMenu.Separator />
|
||||||
<MainMenu.DefaultItems.Preferences />
|
|
||||||
<MainMenu.DefaultItems.ToggleTheme
|
<MainMenu.DefaultItems.ToggleTheme
|
||||||
allowSystemTheme
|
allowSystemTheme
|
||||||
theme={props.theme}
|
theme={props.theme}
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
.excalidraw {
|
|
||||||
.app-sidebar-promo-container {
|
|
||||||
padding: 0.75rem;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
text-align: center;
|
|
||||||
gap: 1rem;
|
|
||||||
flex: 1 1 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.app-sidebar-promo-image {
|
|
||||||
margin: 1rem 0;
|
|
||||||
|
|
||||||
height: 16.25rem;
|
|
||||||
background-size: contain;
|
|
||||||
background-position: center;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
|
|
||||||
background-image: radial-gradient(
|
|
||||||
circle,
|
|
||||||
transparent 60%,
|
|
||||||
var(--sidebar-bg-color) 100%
|
|
||||||
),
|
|
||||||
var(--image-source);
|
|
||||||
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.app-sidebar-promo-text {
|
|
||||||
padding: 0 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.link-button {
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
import { DefaultSidebar, Sidebar, THEME } from "@excalidraw/excalidraw";
|
|
||||||
import {
|
|
||||||
messageCircleIcon,
|
|
||||||
presentationIcon,
|
|
||||||
} from "@excalidraw/excalidraw/components/icons";
|
|
||||||
import { LinkButton } from "@excalidraw/excalidraw/components/LinkButton";
|
|
||||||
import { useUIAppState } from "@excalidraw/excalidraw/context/ui-appState";
|
|
||||||
|
|
||||||
import "./AppSidebar.scss";
|
|
||||||
|
|
||||||
export const AppSidebar = () => {
|
|
||||||
const { theme, openSidebar } = useUIAppState();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<DefaultSidebar>
|
|
||||||
<DefaultSidebar.TabTriggers>
|
|
||||||
<Sidebar.TabTrigger
|
|
||||||
tab="comments"
|
|
||||||
style={{ opacity: openSidebar?.tab === "comments" ? 1 : 0.4 }}
|
|
||||||
>
|
|
||||||
{messageCircleIcon}
|
|
||||||
</Sidebar.TabTrigger>
|
|
||||||
<Sidebar.TabTrigger
|
|
||||||
tab="presentation"
|
|
||||||
style={{ opacity: openSidebar?.tab === "presentation" ? 1 : 0.4 }}
|
|
||||||
>
|
|
||||||
{presentationIcon}
|
|
||||||
</Sidebar.TabTrigger>
|
|
||||||
</DefaultSidebar.TabTriggers>
|
|
||||||
<Sidebar.Tab tab="comments">
|
|
||||||
<div className="app-sidebar-promo-container">
|
|
||||||
<div
|
|
||||||
className="app-sidebar-promo-image"
|
|
||||||
style={{
|
|
||||||
["--image-source" as any]: `url(/oss_promo_comments_${
|
|
||||||
theme === THEME.DARK ? "dark" : "light"
|
|
||||||
}.jpg)`,
|
|
||||||
opacity: 0.7,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className="app-sidebar-promo-text">
|
|
||||||
Make comments with Excalidraw+
|
|
||||||
</div>
|
|
||||||
<LinkButton
|
|
||||||
href={`${
|
|
||||||
import.meta.env.VITE_APP_PLUS_LP
|
|
||||||
}/plus?utm_source=excalidraw&utm_medium=app&utm_content=comments_promo#excalidraw-redirect`}
|
|
||||||
>
|
|
||||||
Sign up now
|
|
||||||
</LinkButton>
|
|
||||||
</div>
|
|
||||||
</Sidebar.Tab>
|
|
||||||
<Sidebar.Tab tab="presentation" className="px-3">
|
|
||||||
<div className="app-sidebar-promo-container">
|
|
||||||
<div
|
|
||||||
className="app-sidebar-promo-image"
|
|
||||||
style={{
|
|
||||||
["--image-source" as any]: `url(/oss_promo_presentations_${
|
|
||||||
theme === THEME.DARK ? "dark" : "light"
|
|
||||||
}.svg)`,
|
|
||||||
backgroundSize: "60%",
|
|
||||||
opacity: 0.4,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<div className="app-sidebar-promo-text">
|
|
||||||
Create presentations with Excalidraw+
|
|
||||||
</div>
|
|
||||||
<LinkButton
|
|
||||||
href={`${
|
|
||||||
import.meta.env.VITE_APP_PLUS_LP
|
|
||||||
}/plus?utm_source=excalidraw&utm_medium=app&utm_content=presentations_promo#excalidraw-redirect`}
|
|
||||||
>
|
|
||||||
Sign up now
|
|
||||||
</LinkButton>
|
|
||||||
</div>
|
|
||||||
</Sidebar.Tab>
|
|
||||||
</DefaultSidebar>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
|
import React from "react";
|
||||||
import { loginIcon } from "@excalidraw/excalidraw/components/icons";
|
import { loginIcon } from "@excalidraw/excalidraw/components/icons";
|
||||||
import { POINTER_EVENTS } from "@excalidraw/common";
|
|
||||||
import { useI18n } from "@excalidraw/excalidraw/i18n";
|
import { useI18n } from "@excalidraw/excalidraw/i18n";
|
||||||
import { WelcomeScreen } from "@excalidraw/excalidraw/index";
|
import { WelcomeScreen } from "@excalidraw/excalidraw/index";
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
import { isExcalidrawPlusSignedUser } from "../app_constants";
|
import { isExcalidrawPlusSignedUser } from "../app_constants";
|
||||||
|
import { POINTER_EVENTS } from "@excalidraw/excalidraw/constants";
|
||||||
|
|
||||||
export const AppWelcomeScreen: React.FC<{
|
export const AppWelcomeScreen: React.FC<{
|
||||||
onCollabDialogOpen: () => any;
|
onCollabDialogOpen: () => any;
|
||||||
@@ -33,15 +32,7 @@ export const AppWelcomeScreen: React.FC<{
|
|||||||
return bit;
|
return bit;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
headingContent = (
|
headingContent = t("welcomeScreen.app.center_heading");
|
||||||
<>
|
|
||||||
{t("welcomeScreen.app.center_heading")}
|
|
||||||
<br />
|
|
||||||
{t("welcomeScreen.app.center_heading_line2")}
|
|
||||||
<br />
|
|
||||||
{t("welcomeScreen.app.center_heading_line3")}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,45 +1,24 @@
|
|||||||
|
import { useCallback, useImperativeHandle, useRef } from "react";
|
||||||
|
import { type AppState } from "@excalidraw/excalidraw/types";
|
||||||
|
import { throttleRAF } from "@excalidraw/excalidraw/utils";
|
||||||
|
import {
|
||||||
|
bootstrapCanvas,
|
||||||
|
getNormalizedCanvasDimensions,
|
||||||
|
} from "@excalidraw/excalidraw/renderer/helpers";
|
||||||
|
import type { DebugElement } from "@excalidraw/excalidraw/visualdebug";
|
||||||
import {
|
import {
|
||||||
ArrowheadArrowIcon,
|
ArrowheadArrowIcon,
|
||||||
CloseIcon,
|
CloseIcon,
|
||||||
TrashIcon,
|
TrashIcon,
|
||||||
} from "@excalidraw/excalidraw/components/icons";
|
} from "@excalidraw/excalidraw/components/icons";
|
||||||
import {
|
import { STORAGE_KEYS } from "../app_constants";
|
||||||
bootstrapCanvas,
|
import type { Curve } from "../../packages/math";
|
||||||
getNormalizedCanvasDimensions,
|
|
||||||
} from "@excalidraw/excalidraw/renderer/helpers";
|
|
||||||
import { type AppState } from "@excalidraw/excalidraw/types";
|
|
||||||
import { arrayToMap, throttleRAF } from "@excalidraw/common";
|
|
||||||
import { useCallback } from "react";
|
|
||||||
|
|
||||||
import {
|
|
||||||
getGlobalFixedPointForBindableElement,
|
|
||||||
isArrowElement,
|
|
||||||
isBindableElement,
|
|
||||||
} from "@excalidraw/element";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
isLineSegment,
|
isLineSegment,
|
||||||
type GlobalPoint,
|
type GlobalPoint,
|
||||||
type LineSegment,
|
type LineSegment,
|
||||||
} from "@excalidraw/math";
|
} from "../../packages/math";
|
||||||
import { isCurve } from "@excalidraw/math/curve";
|
import { isCurve } from "../../packages/math/curve";
|
||||||
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
import type { Curve } from "@excalidraw/math";
|
|
||||||
import type {
|
|
||||||
DebugElement,
|
|
||||||
DebugPolygon,
|
|
||||||
} from "@excalidraw/element/visualdebug";
|
|
||||||
import type {
|
|
||||||
ElementsMap,
|
|
||||||
ExcalidrawArrowElement,
|
|
||||||
ExcalidrawBindableElement,
|
|
||||||
FixedPointBinding,
|
|
||||||
OrderedExcalidrawElement,
|
|
||||||
} from "@excalidraw/element/types";
|
|
||||||
|
|
||||||
import { STORAGE_KEYS } from "../app_constants";
|
|
||||||
|
|
||||||
const renderLine = (
|
const renderLine = (
|
||||||
context: CanvasRenderingContext2D,
|
context: CanvasRenderingContext2D,
|
||||||
@@ -78,44 +57,6 @@ const renderCubicBezier = (
|
|||||||
context.restore();
|
context.restore();
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderPolygon = (
|
|
||||||
context: CanvasRenderingContext2D,
|
|
||||||
zoom: number,
|
|
||||||
polygon: DebugPolygon,
|
|
||||||
color: string,
|
|
||||||
) => {
|
|
||||||
const { points, fill, close } = polygon;
|
|
||||||
|
|
||||||
if (points.length < 2) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.save();
|
|
||||||
context.beginPath();
|
|
||||||
context.moveTo(points[0][0] * zoom, points[0][1] * zoom);
|
|
||||||
for (let i = 1; i < points.length; i += 1) {
|
|
||||||
context.lineTo(points[i][0] * zoom, points[i][1] * zoom);
|
|
||||||
}
|
|
||||||
if (close !== false) {
|
|
||||||
context.closePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fill) {
|
|
||||||
context.save();
|
|
||||||
context.globalAlpha = 0.15;
|
|
||||||
context.fillStyle = color;
|
|
||||||
context.fill();
|
|
||||||
context.restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
context.strokeStyle = color;
|
|
||||||
context.stroke();
|
|
||||||
context.restore();
|
|
||||||
};
|
|
||||||
|
|
||||||
const isDebugPolygon = (data: DebugElement["data"]): data is DebugPolygon =>
|
|
||||||
(data as DebugPolygon).type === "polygon";
|
|
||||||
|
|
||||||
const renderOrigin = (context: CanvasRenderingContext2D, zoom: number) => {
|
const renderOrigin = (context: CanvasRenderingContext2D, zoom: number) => {
|
||||||
context.strokeStyle = "#888";
|
context.strokeStyle = "#888";
|
||||||
context.save();
|
context.save();
|
||||||
@@ -128,176 +69,6 @@ const renderOrigin = (context: CanvasRenderingContext2D, zoom: number) => {
|
|||||||
context.save();
|
context.save();
|
||||||
};
|
};
|
||||||
|
|
||||||
const _renderBinding = (
|
|
||||||
context: CanvasRenderingContext2D,
|
|
||||||
binding: FixedPointBinding,
|
|
||||||
elementsMap: ElementsMap,
|
|
||||||
zoom: number,
|
|
||||||
width: number,
|
|
||||||
height: number,
|
|
||||||
color: string,
|
|
||||||
) => {
|
|
||||||
if (!binding.fixedPoint) {
|
|
||||||
console.warn("Binding must have a fixedPoint");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bindable = elementsMap.get(
|
|
||||||
binding.elementId,
|
|
||||||
) as ExcalidrawBindableElement;
|
|
||||||
const [x, y] = getGlobalFixedPointForBindableElement(
|
|
||||||
binding.fixedPoint,
|
|
||||||
bindable,
|
|
||||||
elementsMap,
|
|
||||||
);
|
|
||||||
|
|
||||||
context.save();
|
|
||||||
context.strokeStyle = color;
|
|
||||||
context.lineWidth = 1;
|
|
||||||
context.beginPath();
|
|
||||||
context.moveTo(x * zoom, y * zoom);
|
|
||||||
context.bezierCurveTo(
|
|
||||||
x * zoom - width,
|
|
||||||
y * zoom - height,
|
|
||||||
x * zoom - width,
|
|
||||||
y * zoom + height,
|
|
||||||
x * zoom,
|
|
||||||
y * zoom,
|
|
||||||
);
|
|
||||||
context.stroke();
|
|
||||||
context.restore();
|
|
||||||
};
|
|
||||||
|
|
||||||
const _renderBindableBinding = (
|
|
||||||
binding: FixedPointBinding,
|
|
||||||
context: CanvasRenderingContext2D,
|
|
||||||
elementsMap: ElementsMap,
|
|
||||||
zoom: number,
|
|
||||||
width: number,
|
|
||||||
height: number,
|
|
||||||
color: string,
|
|
||||||
) => {
|
|
||||||
const bindable = elementsMap.get(
|
|
||||||
binding.elementId,
|
|
||||||
) as ExcalidrawBindableElement;
|
|
||||||
if (!binding.fixedPoint) {
|
|
||||||
console.warn("Binding must have a fixedPoint");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [x, y] = getGlobalFixedPointForBindableElement(
|
|
||||||
binding.fixedPoint,
|
|
||||||
bindable,
|
|
||||||
elementsMap,
|
|
||||||
);
|
|
||||||
|
|
||||||
context.save();
|
|
||||||
context.strokeStyle = color;
|
|
||||||
context.lineWidth = 1;
|
|
||||||
context.beginPath();
|
|
||||||
context.moveTo(x * zoom, y * zoom);
|
|
||||||
context.bezierCurveTo(
|
|
||||||
x * zoom + width,
|
|
||||||
y * zoom + height,
|
|
||||||
x * zoom + width,
|
|
||||||
y * zoom - height,
|
|
||||||
x * zoom,
|
|
||||||
y * zoom,
|
|
||||||
);
|
|
||||||
context.stroke();
|
|
||||||
context.restore();
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderBindings = (
|
|
||||||
context: CanvasRenderingContext2D,
|
|
||||||
elements: readonly OrderedExcalidrawElement[],
|
|
||||||
zoom: number,
|
|
||||||
) => {
|
|
||||||
const elementsMap = arrayToMap(elements);
|
|
||||||
const dim = 16;
|
|
||||||
elements.forEach((element) => {
|
|
||||||
if (element.isDeleted) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isArrowElement(element)) {
|
|
||||||
if (element.startBinding) {
|
|
||||||
if (
|
|
||||||
!elementsMap
|
|
||||||
.get(element.startBinding.elementId)
|
|
||||||
?.boundElements?.find((e) => e.id === element.id)
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_renderBinding(
|
|
||||||
context,
|
|
||||||
element.startBinding,
|
|
||||||
elementsMap,
|
|
||||||
zoom,
|
|
||||||
dim,
|
|
||||||
dim,
|
|
||||||
element.startBinding?.mode === "orbit" ? "red" : "black",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (element.endBinding) {
|
|
||||||
if (
|
|
||||||
!elementsMap
|
|
||||||
.get(element.endBinding.elementId)
|
|
||||||
?.boundElements?.find((e) => e.id === element.id)
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_renderBinding(
|
|
||||||
context,
|
|
||||||
element.endBinding,
|
|
||||||
elementsMap,
|
|
||||||
zoom,
|
|
||||||
dim,
|
|
||||||
dim,
|
|
||||||
element.endBinding?.mode === "orbit" ? "red" : "black",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isBindableElement(element) && element.boundElements?.length) {
|
|
||||||
element.boundElements.forEach((boundElement) => {
|
|
||||||
if (boundElement.type !== "arrow") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const arrow = elementsMap.get(
|
|
||||||
boundElement.id,
|
|
||||||
) as ExcalidrawArrowElement;
|
|
||||||
|
|
||||||
if (arrow && arrow.startBinding?.elementId === element.id) {
|
|
||||||
_renderBindableBinding(
|
|
||||||
arrow.startBinding,
|
|
||||||
context,
|
|
||||||
elementsMap,
|
|
||||||
zoom,
|
|
||||||
dim,
|
|
||||||
dim,
|
|
||||||
"green",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (arrow && arrow.endBinding?.elementId === element.id) {
|
|
||||||
_renderBindableBinding(
|
|
||||||
arrow.endBinding,
|
|
||||||
context,
|
|
||||||
elementsMap,
|
|
||||||
zoom,
|
|
||||||
dim,
|
|
||||||
dim,
|
|
||||||
"green",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const render = (
|
const render = (
|
||||||
frame: DebugElement[],
|
frame: DebugElement[],
|
||||||
context: CanvasRenderingContext2D,
|
context: CanvasRenderingContext2D,
|
||||||
@@ -321,9 +92,6 @@ const render = (
|
|||||||
el.color,
|
el.color,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case isDebugPolygon(el.data):
|
|
||||||
renderPolygon(context, appState.zoom.value, el.data, el.color);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unknown element type ${JSON.stringify(el)}`);
|
throw new Error(`Unknown element type ${JSON.stringify(el)}`);
|
||||||
}
|
}
|
||||||
@@ -333,14 +101,18 @@ const render = (
|
|||||||
const _debugRenderer = (
|
const _debugRenderer = (
|
||||||
canvas: HTMLCanvasElement,
|
canvas: HTMLCanvasElement,
|
||||||
appState: AppState,
|
appState: AppState,
|
||||||
elements: readonly OrderedExcalidrawElement[],
|
|
||||||
scale: number,
|
scale: number,
|
||||||
|
refresh: () => void,
|
||||||
) => {
|
) => {
|
||||||
const [normalizedWidth, normalizedHeight] = getNormalizedCanvasDimensions(
|
const [normalizedWidth, normalizedHeight] = getNormalizedCanvasDimensions(
|
||||||
canvas,
|
canvas,
|
||||||
scale,
|
scale,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (appState.height !== canvas.height || appState.width !== canvas.width) {
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
const context = bootstrapCanvas({
|
const context = bootstrapCanvas({
|
||||||
canvas,
|
canvas,
|
||||||
scale,
|
scale,
|
||||||
@@ -357,7 +129,6 @@ const _debugRenderer = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
renderOrigin(context, appState.zoom.value);
|
renderOrigin(context, appState.zoom.value);
|
||||||
renderBindings(context, elements, appState.zoom.value);
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
window.visualDebug?.currentFrame &&
|
window.visualDebug?.currentFrame &&
|
||||||
@@ -409,11 +180,12 @@ export const debugRenderer = throttleRAF(
|
|||||||
(
|
(
|
||||||
canvas: HTMLCanvasElement,
|
canvas: HTMLCanvasElement,
|
||||||
appState: AppState,
|
appState: AppState,
|
||||||
elements: readonly OrderedExcalidrawElement[],
|
|
||||||
scale: number,
|
scale: number,
|
||||||
|
refresh: () => void,
|
||||||
) => {
|
) => {
|
||||||
_debugRenderer(canvas, appState, elements, scale);
|
_debugRenderer(canvas, appState, scale, refresh);
|
||||||
},
|
},
|
||||||
|
{ trailing: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
export const loadSavedDebugState = () => {
|
export const loadSavedDebugState = () => {
|
||||||
@@ -538,29 +310,35 @@ export const DebugFooter = ({ onChange }: { onChange: () => void }) => {
|
|||||||
interface DebugCanvasProps {
|
interface DebugCanvasProps {
|
||||||
appState: AppState;
|
appState: AppState;
|
||||||
scale: number;
|
scale: number;
|
||||||
|
ref?: React.Ref<HTMLCanvasElement>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DebugCanvas = React.forwardRef<HTMLCanvasElement, DebugCanvasProps>(
|
const DebugCanvas = ({ appState, scale, ref }: DebugCanvasProps) => {
|
||||||
({ appState, scale }, ref) => {
|
const { width, height } = appState;
|
||||||
const { width, height } = appState;
|
|
||||||
|
|
||||||
return (
|
const canvasRef = useRef<HTMLCanvasElement>(null);
|
||||||
<canvas
|
useImperativeHandle<HTMLCanvasElement | null, HTMLCanvasElement | null>(
|
||||||
style={{
|
ref,
|
||||||
width,
|
() => canvasRef.current,
|
||||||
height,
|
[canvasRef],
|
||||||
position: "absolute",
|
);
|
||||||
zIndex: 2,
|
|
||||||
pointerEvents: "none",
|
return (
|
||||||
}}
|
<canvas
|
||||||
width={width * scale}
|
style={{
|
||||||
height={height * scale}
|
width,
|
||||||
ref={ref}
|
height,
|
||||||
>
|
position: "absolute",
|
||||||
Debug Canvas
|
zIndex: 2,
|
||||||
</canvas>
|
pointerEvents: "none",
|
||||||
);
|
}}
|
||||||
},
|
width={width * scale}
|
||||||
);
|
height={height * scale}
|
||||||
|
ref={canvasRef}
|
||||||
|
>
|
||||||
|
Debug Canvas
|
||||||
|
</canvas>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default DebugCanvas;
|
export default DebugCanvas;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Tooltip } from "@excalidraw/excalidraw/components/Tooltip";
|
|
||||||
import { shield } from "@excalidraw/excalidraw/components/icons";
|
import { shield } from "@excalidraw/excalidraw/components/icons";
|
||||||
|
import { Tooltip } from "@excalidraw/excalidraw/components/Tooltip";
|
||||||
import { useI18n } from "@excalidraw/excalidraw/i18n";
|
import { useI18n } from "@excalidraw/excalidraw/i18n";
|
||||||
|
|
||||||
export const EncryptedIcon = () => {
|
export const EncryptedIcon = () => {
|
||||||
@@ -10,7 +10,7 @@ export const EncryptedIcon = () => {
|
|||||||
className="encrypted-icon tooltip"
|
className="encrypted-icon tooltip"
|
||||||
href="https://plus.excalidraw.com/blog/end-to-end-encryption"
|
href="https://plus.excalidraw.com/blog/end-to-end-encryption"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener"
|
rel="noopener noreferrer"
|
||||||
aria-label={t("encrypted.link")}
|
aria-label={t("encrypted.link")}
|
||||||
>
|
>
|
||||||
<Tooltip label={t("encrypted.tooltip")} long={true}>
|
<Tooltip label={t("encrypted.tooltip")} long={true}>
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { isExcalidrawPlusSignedUser } from "../app_constants";
|
||||||
|
|
||||||
|
export const ExcalidrawPlusAppLink = () => {
|
||||||
|
if (!isExcalidrawPlusSignedUser) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
href={`${
|
||||||
|
import.meta.env.VITE_APP_PLUS_APP
|
||||||
|
}?utm_source=excalidraw&utm_medium=app&utm_content=signedInUserRedirectButton#excalidraw-redirect`}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
className="plus-button"
|
||||||
|
>
|
||||||
|
Go to Excalidraw+
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
export const ExcalidrawPlusPromoBanner = ({
|
|
||||||
isSignedIn,
|
|
||||||
}: {
|
|
||||||
isSignedIn: boolean;
|
|
||||||
}) => {
|
|
||||||
return (
|
|
||||||
<a
|
|
||||||
href={
|
|
||||||
isSignedIn
|
|
||||||
? import.meta.env.VITE_APP_PLUS_APP
|
|
||||||
: `${
|
|
||||||
import.meta.env.VITE_APP_PLUS_LP
|
|
||||||
}/plus?utm_source=excalidraw&utm_medium=app&utm_content=guestBanner#excalidraw-redirect`
|
|
||||||
}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener"
|
|
||||||
className="plus-banner"
|
|
||||||
>
|
|
||||||
Excalidraw+
|
|
||||||
</a>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,33 +1,31 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { uploadBytes, ref } from "firebase/storage";
|
|
||||||
import { nanoid } from "nanoid";
|
|
||||||
|
|
||||||
import { trackEvent } from "@excalidraw/excalidraw/analytics";
|
|
||||||
import { Card } from "@excalidraw/excalidraw/components/Card";
|
import { Card } from "@excalidraw/excalidraw/components/Card";
|
||||||
import { ExcalidrawLogo } from "@excalidraw/excalidraw/components/ExcalidrawLogo";
|
|
||||||
import { ToolButton } from "@excalidraw/excalidraw/components/ToolButton";
|
import { ToolButton } from "@excalidraw/excalidraw/components/ToolButton";
|
||||||
import { MIME_TYPES, getFrame } from "@excalidraw/common";
|
|
||||||
import {
|
|
||||||
encryptData,
|
|
||||||
generateEncryptionKey,
|
|
||||||
} from "@excalidraw/excalidraw/data/encryption";
|
|
||||||
import { serializeAsJSON } from "@excalidraw/excalidraw/data/json";
|
import { serializeAsJSON } from "@excalidraw/excalidraw/data/json";
|
||||||
import { isInitializedImageElement } from "@excalidraw/element";
|
import { loadFirebaseStorage, saveFilesToFirebase } from "../data/firebase";
|
||||||
import { useI18n } from "@excalidraw/excalidraw/i18n";
|
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
FileId,
|
FileId,
|
||||||
NonDeletedExcalidrawElement,
|
NonDeletedExcalidrawElement,
|
||||||
} from "@excalidraw/element/types";
|
} from "@excalidraw/excalidraw/element/types";
|
||||||
import type {
|
import type {
|
||||||
AppState,
|
AppState,
|
||||||
BinaryFileData,
|
BinaryFileData,
|
||||||
BinaryFiles,
|
BinaryFiles,
|
||||||
} from "@excalidraw/excalidraw/types";
|
} from "@excalidraw/excalidraw/types";
|
||||||
|
import { nanoid } from "nanoid";
|
||||||
|
import { useI18n } from "@excalidraw/excalidraw/i18n";
|
||||||
|
import {
|
||||||
|
encryptData,
|
||||||
|
generateEncryptionKey,
|
||||||
|
} from "@excalidraw/excalidraw/data/encryption";
|
||||||
|
import { isInitializedImageElement } from "@excalidraw/excalidraw/element/typeChecks";
|
||||||
import { FILE_UPLOAD_MAX_BYTES } from "../app_constants";
|
import { FILE_UPLOAD_MAX_BYTES } from "../app_constants";
|
||||||
import { encodeFilesForUpload } from "../data/FileManager";
|
import { encodeFilesForUpload } from "../data/FileManager";
|
||||||
import { loadFirebaseStorage, saveFilesToFirebase } from "../data/firebase";
|
import { uploadBytes, ref } from "firebase/storage";
|
||||||
|
import { MIME_TYPES } from "@excalidraw/excalidraw/constants";
|
||||||
|
import { trackEvent } from "@excalidraw/excalidraw/analytics";
|
||||||
|
import { getFrame } from "@excalidraw/excalidraw/utils";
|
||||||
|
import { ExcalidrawLogo } from "@excalidraw/excalidraw/components/ExcalidrawLogo";
|
||||||
|
|
||||||
export const exportToExcalidrawPlus = async (
|
export const exportToExcalidrawPlus = async (
|
||||||
elements: readonly NonDeletedExcalidrawElement[],
|
elements: readonly NonDeletedExcalidrawElement[],
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import oc from "open-color";
|
||||||
|
import React from "react";
|
||||||
|
import { THEME } from "@excalidraw/excalidraw/constants";
|
||||||
|
import type { Theme } from "@excalidraw/excalidraw/element/types";
|
||||||
|
|
||||||
|
// https://github.com/tholman/github-corners
|
||||||
|
export const GitHubCorner = React.memo(
|
||||||
|
({ theme, dir }: { theme: Theme; dir: string }) => (
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="40"
|
||||||
|
height="40"
|
||||||
|
viewBox="0 0 250 250"
|
||||||
|
className="rtl-mirror"
|
||||||
|
style={{
|
||||||
|
marginTop: "calc(var(--space-factor) * -1)",
|
||||||
|
[dir === "rtl" ? "marginLeft" : "marginRight"]:
|
||||||
|
"calc(var(--space-factor) * -1)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
href="https://github.com/excalidraw/excalidraw"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
aria-label="GitHub repository"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M0 0l115 115h15l12 27 108 108V0z"
|
||||||
|
fill={theme === THEME.LIGHT ? oc.gray[6] : oc.gray[7]}
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
className="octo-arm"
|
||||||
|
d="M128 109c-15-9-9-19-9-19 3-7 2-11 2-11-1-7 3-2 3-2 4 5 2 11 2 11-3 10 5 15 9 16"
|
||||||
|
style={{ transformOrigin: "130px 106px" }}
|
||||||
|
fill={theme === THEME.LIGHT ? oc.white : "var(--default-bg-color)"}
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
className="octo-body"
|
||||||
|
d="M115 115s4 2 5 0l14-14c3-2 6-3 8-3-8-11-15-24 2-41 5-5 10-7 16-7 1-2 3-7 12-11 0 0 5 3 7 16 4 2 8 5 12 9s7 8 9 12c14 3 17 7 17 7-4 8-9 11-11 11 0 6-2 11-7 16-16 16-30 10-41 2 0 3-1 7-5 11l-12 11c-1 1 1 5 1 5z"
|
||||||
|
fill={theme === THEME.LIGHT ? oc.white : "var(--default-bg-color)"}
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
</svg>
|
||||||
|
),
|
||||||
|
);
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import Trans from "@excalidraw/excalidraw/components/Trans";
|
|
||||||
import { t } from "@excalidraw/excalidraw/i18n";
|
|
||||||
import * as Sentry from "@sentry/browser";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import * as Sentry from "@sentry/browser";
|
||||||
|
import { t } from "@excalidraw/excalidraw/i18n";
|
||||||
|
import Trans from "@excalidraw/excalidraw/components/Trans";
|
||||||
|
|
||||||
interface TopErrorBoundaryState {
|
interface TopErrorBoundaryState {
|
||||||
hasError: boolean;
|
hasError: boolean;
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import { CaptureUpdateAction } from "@excalidraw/excalidraw";
|
import { CaptureUpdateAction } from "@excalidraw/excalidraw";
|
||||||
import { compressData } from "@excalidraw/excalidraw/data/encode";
|
import { compressData } from "@excalidraw/excalidraw/data/encode";
|
||||||
import { newElementWith } from "@excalidraw/element";
|
import { newElementWith } from "@excalidraw/excalidraw/element/mutateElement";
|
||||||
import { isInitializedImageElement } from "@excalidraw/element";
|
import { isInitializedImageElement } from "@excalidraw/excalidraw/element/typeChecks";
|
||||||
import { t } from "@excalidraw/excalidraw/i18n";
|
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
ExcalidrawElement,
|
ExcalidrawElement,
|
||||||
ExcalidrawImageElement,
|
ExcalidrawImageElement,
|
||||||
FileId,
|
FileId,
|
||||||
InitializedExcalidrawImageElement,
|
InitializedExcalidrawImageElement,
|
||||||
} from "@excalidraw/element/types";
|
} from "@excalidraw/excalidraw/element/types";
|
||||||
|
import { t } from "@excalidraw/excalidraw/i18n";
|
||||||
import type {
|
import type {
|
||||||
BinaryFileData,
|
BinaryFileData,
|
||||||
BinaryFileMetadata,
|
BinaryFileMetadata,
|
||||||
@@ -40,12 +39,10 @@ export class FileManager {
|
|||||||
|
|
||||||
private _getFiles;
|
private _getFiles;
|
||||||
private _saveFiles;
|
private _saveFiles;
|
||||||
private _onFileStatusChange;
|
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
getFiles,
|
getFiles,
|
||||||
saveFiles,
|
saveFiles,
|
||||||
onFileStatusChange,
|
|
||||||
}: {
|
}: {
|
||||||
getFiles: (fileIds: FileId[]) => Promise<{
|
getFiles: (fileIds: FileId[]) => Promise<{
|
||||||
loadedFiles: BinaryFileData[];
|
loadedFiles: BinaryFileData[];
|
||||||
@@ -55,13 +52,9 @@ export class FileManager {
|
|||||||
savedFiles: Map<FileId, BinaryFileData>;
|
savedFiles: Map<FileId, BinaryFileData>;
|
||||||
erroredFiles: Map<FileId, BinaryFileData>;
|
erroredFiles: Map<FileId, BinaryFileData>;
|
||||||
}>;
|
}>;
|
||||||
onFileStatusChange?: (
|
|
||||||
updates: Array<[FileId, "loading" | "loaded" | "error"]>,
|
|
||||||
) => void;
|
|
||||||
}) {
|
}) {
|
||||||
this._getFiles = getFiles;
|
this._getFiles = getFiles;
|
||||||
this._saveFiles = saveFiles;
|
this._saveFiles = saveFiles;
|
||||||
this._onFileStatusChange = onFileStatusChange;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,8 +145,6 @@ export class FileManager {
|
|||||||
this.fetchingFiles.set(id, true);
|
this.fetchingFiles.set(id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._onFileStatusChange?.(ids.map((id) => [id, "loading"]));
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { loadedFiles, erroredFiles } = await this._getFiles(ids);
|
const { loadedFiles, erroredFiles } = await this._getFiles(ids);
|
||||||
|
|
||||||
@@ -164,13 +155,6 @@ export class FileManager {
|
|||||||
this.erroredFiles_fetch.set(fileId, true);
|
this.erroredFiles_fetch.set(fileId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._onFileStatusChange?.([
|
|
||||||
...loadedFiles.map((f) => [f.id, "loaded"] as [FileId, "loaded"]),
|
|
||||||
...[...erroredFiles.keys()].map(
|
|
||||||
(id) => [id, "error"] as [FileId, "error"],
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return { loadedFiles, erroredFiles };
|
return { loadedFiles, erroredFiles };
|
||||||
} finally {
|
} finally {
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
@@ -210,13 +194,6 @@ export class FileManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
if (this._onFileStatusChange && this.fetchingFiles.size) {
|
|
||||||
this._onFileStatusChange(
|
|
||||||
[...this.fetchingFiles.keys()].map(
|
|
||||||
(id) => [id, "error"] as [FileId, "error"],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
this.fetchingFiles.clear();
|
this.fetchingFiles.clear();
|
||||||
this.savingFiles.clear();
|
this.savingFiles.clear();
|
||||||
this.savedFiles.clear();
|
this.savedFiles.clear();
|
||||||
|
|||||||
@@ -10,12 +10,6 @@
|
|||||||
* (localStorage, indexedDB).
|
* (localStorage, indexedDB).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { clearAppStateForLocalStorage } from "@excalidraw/excalidraw/appState";
|
|
||||||
import {
|
|
||||||
CANVAS_SEARCH_TAB,
|
|
||||||
DEFAULT_SIDEBAR,
|
|
||||||
debounce,
|
|
||||||
} from "@excalidraw/common";
|
|
||||||
import {
|
import {
|
||||||
createStore,
|
createStore,
|
||||||
entries,
|
entries,
|
||||||
@@ -25,31 +19,32 @@ import {
|
|||||||
setMany,
|
setMany,
|
||||||
get,
|
get,
|
||||||
} from "idb-keyval";
|
} from "idb-keyval";
|
||||||
|
import { clearAppStateForLocalStorage } from "@excalidraw/excalidraw/appState";
|
||||||
import { appJotaiStore, atom } from "excalidraw-app/app-jotai";
|
import {
|
||||||
import { getNonDeletedElements } from "@excalidraw/element";
|
CANVAS_SEARCH_TAB,
|
||||||
|
DEFAULT_SIDEBAR,
|
||||||
|
} from "@excalidraw/excalidraw/constants";
|
||||||
import type { LibraryPersistedData } from "@excalidraw/excalidraw/data/library";
|
import type { LibraryPersistedData } from "@excalidraw/excalidraw/data/library";
|
||||||
import type { ImportedDataState } from "@excalidraw/excalidraw/data/types";
|
import type { ImportedDataState } from "@excalidraw/excalidraw/data/types";
|
||||||
import type { ExcalidrawElement, FileId } from "@excalidraw/element/types";
|
import { clearElementsForLocalStorage } from "@excalidraw/excalidraw/element";
|
||||||
|
import type {
|
||||||
|
ExcalidrawElement,
|
||||||
|
FileId,
|
||||||
|
} from "@excalidraw/excalidraw/element/types";
|
||||||
import type {
|
import type {
|
||||||
AppState,
|
AppState,
|
||||||
BinaryFileData,
|
BinaryFileData,
|
||||||
BinaryFiles,
|
BinaryFiles,
|
||||||
} from "@excalidraw/excalidraw/types";
|
} from "@excalidraw/excalidraw/types";
|
||||||
import type { MaybePromise } from "@excalidraw/common/utility-types";
|
import type { MaybePromise } from "@excalidraw/excalidraw/utility-types";
|
||||||
|
import { debounce } from "@excalidraw/excalidraw/utils";
|
||||||
import { SAVE_TO_LOCAL_STORAGE_TIMEOUT, STORAGE_KEYS } from "../app_constants";
|
import { SAVE_TO_LOCAL_STORAGE_TIMEOUT, STORAGE_KEYS } from "../app_constants";
|
||||||
|
|
||||||
import { FileManager } from "./FileManager";
|
import { FileManager } from "./FileManager";
|
||||||
import { FileStatusStore } from "./fileStatusStore";
|
|
||||||
import { Locker } from "./Locker";
|
import { Locker } from "./Locker";
|
||||||
import { updateBrowserStateVersion } from "./tabSync";
|
import { updateBrowserStateVersion } from "./tabSync";
|
||||||
|
|
||||||
const filesStore = createStore("files-db", "files-store");
|
const filesStore = createStore("files-db", "files-store");
|
||||||
|
|
||||||
export const localStorageQuotaExceededAtom = atom(false);
|
|
||||||
|
|
||||||
class LocalFileManager extends FileManager {
|
class LocalFileManager extends FileManager {
|
||||||
clearObsoleteFiles = async (opts: { currentFileIds: FileId[] }) => {
|
clearObsoleteFiles = async (opts: { currentFileIds: FileId[] }) => {
|
||||||
await entries(filesStore).then((entries) => {
|
await entries(filesStore).then((entries) => {
|
||||||
@@ -74,9 +69,6 @@ const saveDataStateToLocalStorage = (
|
|||||||
elements: readonly ExcalidrawElement[],
|
elements: readonly ExcalidrawElement[],
|
||||||
appState: AppState,
|
appState: AppState,
|
||||||
) => {
|
) => {
|
||||||
const localStorageQuotaExceeded = appJotaiStore.get(
|
|
||||||
localStorageQuotaExceededAtom,
|
|
||||||
);
|
|
||||||
try {
|
try {
|
||||||
const _appState = clearAppStateForLocalStorage(appState);
|
const _appState = clearAppStateForLocalStorage(appState);
|
||||||
|
|
||||||
@@ -89,29 +81,19 @@ const saveDataStateToLocalStorage = (
|
|||||||
|
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
STORAGE_KEYS.LOCAL_STORAGE_ELEMENTS,
|
STORAGE_KEYS.LOCAL_STORAGE_ELEMENTS,
|
||||||
JSON.stringify(getNonDeletedElements(elements)),
|
JSON.stringify(clearElementsForLocalStorage(elements)),
|
||||||
);
|
);
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
STORAGE_KEYS.LOCAL_STORAGE_APP_STATE,
|
STORAGE_KEYS.LOCAL_STORAGE_APP_STATE,
|
||||||
JSON.stringify(_appState),
|
JSON.stringify(_appState),
|
||||||
);
|
);
|
||||||
updateBrowserStateVersion(STORAGE_KEYS.VERSION_DATA_STATE);
|
updateBrowserStateVersion(STORAGE_KEYS.VERSION_DATA_STATE);
|
||||||
if (localStorageQuotaExceeded) {
|
|
||||||
appJotaiStore.set(localStorageQuotaExceededAtom, false);
|
|
||||||
}
|
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
// Unable to access window.localStorage
|
// Unable to access window.localStorage
|
||||||
console.error(error);
|
console.error(error);
|
||||||
if (isQuotaExceededError(error) && !localStorageQuotaExceeded) {
|
|
||||||
appJotaiStore.set(localStorageQuotaExceededAtom, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const isQuotaExceededError = (error: any) => {
|
|
||||||
return error instanceof DOMException && error.name === "QuotaExceededError";
|
|
||||||
};
|
|
||||||
|
|
||||||
type SavingLockTypes = "collaboration";
|
type SavingLockTypes = "collaboration";
|
||||||
|
|
||||||
export class LocalData {
|
export class LocalData {
|
||||||
@@ -167,7 +149,6 @@ export class LocalData {
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
static fileStorage = new LocalFileManager({
|
static fileStorage = new LocalFileManager({
|
||||||
onFileStatusChange: FileStatusStore.updateStatuses.bind(FileStatusStore),
|
|
||||||
getFiles(ids) {
|
getFiles(ids) {
|
||||||
return getMany(ids, filesStore).then(
|
return getMany(ids, filesStore).then(
|
||||||
async (filesData: (BinaryFileData | undefined)[]) => {
|
async (filesData: (BinaryFileData | undefined)[]) => {
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
import { createStore, get, set } from "idb-keyval";
|
|
||||||
|
|
||||||
import type { SavedChats } from "@excalidraw/excalidraw/components/TTDDialog/types";
|
|
||||||
|
|
||||||
import { STORAGE_KEYS } from "../app_constants";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IndexedDB adapter for TTD chat storage.
|
|
||||||
* Implements TTDPersistenceAdapter interface.
|
|
||||||
*/
|
|
||||||
export class TTDIndexedDBAdapter {
|
|
||||||
/** IndexedDB database name */
|
|
||||||
private static idb_name = STORAGE_KEYS.IDB_TTD_CHATS;
|
|
||||||
/** Store key for chat data */
|
|
||||||
private static key = "ttdChats";
|
|
||||||
|
|
||||||
private static store = createStore(
|
|
||||||
`${TTDIndexedDBAdapter.idb_name}-db`,
|
|
||||||
`${TTDIndexedDBAdapter.idb_name}-store`,
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load saved chats from IndexedDB.
|
|
||||||
* @returns Promise resolving to saved chats array (empty if none found)
|
|
||||||
*/
|
|
||||||
static async loadChats(): Promise<SavedChats> {
|
|
||||||
try {
|
|
||||||
const data = await get<SavedChats>(
|
|
||||||
TTDIndexedDBAdapter.key,
|
|
||||||
TTDIndexedDBAdapter.store,
|
|
||||||
);
|
|
||||||
return data || [];
|
|
||||||
} catch (error) {
|
|
||||||
console.warn("Failed to load TTD chats from IndexedDB:", error);
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save chats to IndexedDB.
|
|
||||||
* @param chats - The chats array to persist
|
|
||||||
*/
|
|
||||||
static async saveChats(chats: SavedChats): Promise<void> {
|
|
||||||
try {
|
|
||||||
await set(TTDIndexedDBAdapter.key, chats, TTDIndexedDBAdapter.store);
|
|
||||||
} catch (error) {
|
|
||||||
console.warn("Failed to save TTD chats to IndexedDB:", error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
import { VersionedSnapshotStore } from "@excalidraw/common";
|
|
||||||
|
|
||||||
import type { FileId } from "@excalidraw/element/types";
|
|
||||||
|
|
||||||
export type FileLoadingStatus = "loading" | "loaded" | "error";
|
|
||||||
|
|
||||||
export class FileStatusStore {
|
|
||||||
private static store = new VersionedSnapshotStore<
|
|
||||||
Map<FileId, FileLoadingStatus>
|
|
||||||
>(new Map());
|
|
||||||
|
|
||||||
static getSnapshot() {
|
|
||||||
return this.store.getSnapshot();
|
|
||||||
}
|
|
||||||
|
|
||||||
static pull(sinceVersion?: number) {
|
|
||||||
return this.store.pull(sinceVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
static updateStatuses(updates: Array<[FileId, FileLoadingStatus]>) {
|
|
||||||
if (!updates.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.store.update((prev) => {
|
|
||||||
let changed = false;
|
|
||||||
const next = new Map(prev);
|
|
||||||
for (const [id, status] of updates) {
|
|
||||||
if (next.get(id) !== status) {
|
|
||||||
next.set(id, status);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return changed ? next : prev;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static getPendingCount(statuses: Map<FileId, FileLoadingStatus>) {
|
|
||||||
let pending = 0;
|
|
||||||
let total = 0;
|
|
||||||
for (const status of statuses.values()) {
|
|
||||||
total++;
|
|
||||||
if (status === "loading") {
|
|
||||||
pending++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return { pending, total };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,27 @@
|
|||||||
import { reconcileElements } from "@excalidraw/excalidraw";
|
import { reconcileElements } from "@excalidraw/excalidraw";
|
||||||
import { MIME_TYPES, toBrandedType } from "@excalidraw/common";
|
import type {
|
||||||
|
ExcalidrawElement,
|
||||||
|
FileId,
|
||||||
|
OrderedExcalidrawElement,
|
||||||
|
} from "@excalidraw/excalidraw/element/types";
|
||||||
|
import { getSceneVersion } from "@excalidraw/excalidraw/element";
|
||||||
|
import type Portal from "../collab/Portal";
|
||||||
|
import { restoreElements } from "@excalidraw/excalidraw/data/restore";
|
||||||
|
import type {
|
||||||
|
AppState,
|
||||||
|
BinaryFileData,
|
||||||
|
BinaryFileMetadata,
|
||||||
|
DataURL,
|
||||||
|
} from "@excalidraw/excalidraw/types";
|
||||||
|
import { FILE_CACHE_MAX_AGE_SEC } from "../app_constants";
|
||||||
import { decompressData } from "@excalidraw/excalidraw/data/encode";
|
import { decompressData } from "@excalidraw/excalidraw/data/encode";
|
||||||
import {
|
import {
|
||||||
encryptData,
|
encryptData,
|
||||||
decryptData,
|
decryptData,
|
||||||
} from "@excalidraw/excalidraw/data/encryption";
|
} from "@excalidraw/excalidraw/data/encryption";
|
||||||
import { restoreElements } from "@excalidraw/excalidraw/data/restore";
|
import { MIME_TYPES } from "@excalidraw/excalidraw/constants";
|
||||||
import { getSceneVersion } from "@excalidraw/element";
|
import type { SyncableExcalidrawElement } from ".";
|
||||||
|
import { getSyncableElements } from ".";
|
||||||
import { initializeApp } from "firebase/app";
|
import { initializeApp } from "firebase/app";
|
||||||
import {
|
import {
|
||||||
getFirestore,
|
getFirestore,
|
||||||
@@ -16,27 +31,8 @@ import {
|
|||||||
Bytes,
|
Bytes,
|
||||||
} from "firebase/firestore";
|
} from "firebase/firestore";
|
||||||
import { getStorage, ref, uploadBytes } from "firebase/storage";
|
import { getStorage, ref, uploadBytes } from "firebase/storage";
|
||||||
|
|
||||||
import type { RemoteExcalidrawElement } from "@excalidraw/excalidraw/data/reconcile";
|
|
||||||
import type {
|
|
||||||
ExcalidrawElement,
|
|
||||||
FileId,
|
|
||||||
OrderedExcalidrawElement,
|
|
||||||
} from "@excalidraw/element/types";
|
|
||||||
import type {
|
|
||||||
AppState,
|
|
||||||
BinaryFileData,
|
|
||||||
BinaryFileMetadata,
|
|
||||||
DataURL,
|
|
||||||
} from "@excalidraw/excalidraw/types";
|
|
||||||
|
|
||||||
import { FILE_CACHE_MAX_AGE_SEC } from "../app_constants";
|
|
||||||
|
|
||||||
import { getSyncableElements } from ".";
|
|
||||||
|
|
||||||
import type { SyncableExcalidrawElement } from ".";
|
|
||||||
import type Portal from "../collab/Portal";
|
|
||||||
import type { Socket } from "socket.io-client";
|
import type { Socket } from "socket.io-client";
|
||||||
|
import type { RemoteExcalidrawElement } from "@excalidraw/excalidraw/data/reconcile";
|
||||||
|
|
||||||
// private
|
// private
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -105,8 +101,8 @@ const decryptElements = async (
|
|||||||
data: FirebaseStoredScene,
|
data: FirebaseStoredScene,
|
||||||
roomKey: string,
|
roomKey: string,
|
||||||
): Promise<readonly ExcalidrawElement[]> => {
|
): Promise<readonly ExcalidrawElement[]> => {
|
||||||
const ciphertext = data.ciphertext.toUint8Array() as Uint8Array<ArrayBuffer>;
|
const ciphertext = data.ciphertext.toUint8Array();
|
||||||
const iv = data.iv.toUint8Array() as Uint8Array<ArrayBuffer>;
|
const iv = data.iv.toUint8Array();
|
||||||
|
|
||||||
const decrypted = await decryptData(iv, ciphertext, roomKey);
|
const decrypted = await decryptData(iv, ciphertext, roomKey);
|
||||||
const decodedData = new TextDecoder("utf-8").decode(
|
const decodedData = new TextDecoder("utf-8").decode(
|
||||||
@@ -243,7 +239,7 @@ export const saveToFirebase = async (
|
|||||||
|
|
||||||
FirebaseSceneVersionCache.set(socket, storedElements);
|
FirebaseSceneVersionCache.set(socket, storedElements);
|
||||||
|
|
||||||
return toBrandedType<RemoteExcalidrawElement[]>(storedElements);
|
return storedElements;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const loadFromFirebase = async (
|
export const loadFromFirebase = async (
|
||||||
@@ -259,9 +255,7 @@ export const loadFromFirebase = async (
|
|||||||
}
|
}
|
||||||
const storedScene = docSnap.data() as FirebaseStoredScene;
|
const storedScene = docSnap.data() as FirebaseStoredScene;
|
||||||
const elements = getSyncableElements(
|
const elements = getSyncableElements(
|
||||||
restoreElements(await decryptElements(storedScene, roomKey), null, {
|
restoreElements(await decryptElements(storedScene, roomKey), null),
|
||||||
deleteInvisibleElements: true,
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (socket) {
|
if (socket) {
|
||||||
|
|||||||
@@ -8,38 +8,35 @@ import {
|
|||||||
IV_LENGTH_BYTES,
|
IV_LENGTH_BYTES,
|
||||||
} from "@excalidraw/excalidraw/data/encryption";
|
} from "@excalidraw/excalidraw/data/encryption";
|
||||||
import { serializeAsJSON } from "@excalidraw/excalidraw/data/json";
|
import { serializeAsJSON } from "@excalidraw/excalidraw/data/json";
|
||||||
import { isInvisiblySmallElement } from "@excalidraw/element";
|
import { restore } from "@excalidraw/excalidraw/data/restore";
|
||||||
import { isInitializedImageElement } from "@excalidraw/element";
|
|
||||||
import { t } from "@excalidraw/excalidraw/i18n";
|
|
||||||
import { bytesToHexString } from "@excalidraw/common";
|
|
||||||
|
|
||||||
import type { UserIdleState } from "@excalidraw/common";
|
|
||||||
import type { ImportedDataState } from "@excalidraw/excalidraw/data/types";
|
import type { ImportedDataState } from "@excalidraw/excalidraw/data/types";
|
||||||
import type { SceneBounds } from "@excalidraw/element";
|
import type { SceneBounds } from "@excalidraw/excalidraw/element/bounds";
|
||||||
|
import { isInvisiblySmallElement } from "@excalidraw/excalidraw/element/sizeHelpers";
|
||||||
|
import { isInitializedImageElement } from "@excalidraw/excalidraw/element/typeChecks";
|
||||||
import type {
|
import type {
|
||||||
ExcalidrawElement,
|
ExcalidrawElement,
|
||||||
FileId,
|
FileId,
|
||||||
OrderedExcalidrawElement,
|
OrderedExcalidrawElement,
|
||||||
} from "@excalidraw/element/types";
|
} from "@excalidraw/excalidraw/element/types";
|
||||||
|
import { t } from "@excalidraw/excalidraw/i18n";
|
||||||
import type {
|
import type {
|
||||||
AppState,
|
AppState,
|
||||||
BinaryFileData,
|
BinaryFileData,
|
||||||
BinaryFiles,
|
BinaryFiles,
|
||||||
SocketId,
|
SocketId,
|
||||||
} from "@excalidraw/excalidraw/types";
|
} from "@excalidraw/excalidraw/types";
|
||||||
import type { MakeBrand } from "@excalidraw/common/utility-types";
|
import type { UserIdleState } from "@excalidraw/excalidraw/constants";
|
||||||
|
import type { MakeBrand } from "@excalidraw/excalidraw/utility-types";
|
||||||
|
import { bytesToHexString } from "@excalidraw/excalidraw/utils";
|
||||||
|
import type { WS_SUBTYPES } from "../app_constants";
|
||||||
import {
|
import {
|
||||||
DELETED_ELEMENT_TIMEOUT,
|
DELETED_ELEMENT_TIMEOUT,
|
||||||
FILE_UPLOAD_MAX_BYTES,
|
FILE_UPLOAD_MAX_BYTES,
|
||||||
ROOM_ID_BYTES,
|
ROOM_ID_BYTES,
|
||||||
} from "../app_constants";
|
} from "../app_constants";
|
||||||
|
|
||||||
import { encodeFilesForUpload } from "./FileManager";
|
import { encodeFilesForUpload } from "./FileManager";
|
||||||
import { saveFilesToFirebase } from "./firebase";
|
import { saveFilesToFirebase } from "./firebase";
|
||||||
|
|
||||||
import type { WS_SUBTYPES } from "../app_constants";
|
|
||||||
|
|
||||||
export type SyncableExcalidrawElement = OrderedExcalidrawElement &
|
export type SyncableExcalidrawElement = OrderedExcalidrawElement &
|
||||||
MakeBrand<"SyncableExcalidrawElement">;
|
MakeBrand<"SyncableExcalidrawElement">;
|
||||||
|
|
||||||
@@ -83,13 +80,13 @@ export type SocketUpdateDataSource = {
|
|||||||
SCENE_INIT: {
|
SCENE_INIT: {
|
||||||
type: WS_SUBTYPES.INIT;
|
type: WS_SUBTYPES.INIT;
|
||||||
payload: {
|
payload: {
|
||||||
elements: readonly OrderedExcalidrawElement[];
|
elements: readonly ExcalidrawElement[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
SCENE_UPDATE: {
|
SCENE_UPDATE: {
|
||||||
type: WS_SUBTYPES.UPDATE;
|
type: WS_SUBTYPES.UPDATE;
|
||||||
payload: {
|
payload: {
|
||||||
elements: readonly OrderedExcalidrawElement[];
|
elements: readonly ExcalidrawElement[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
MOUSE_LOCATION: {
|
MOUSE_LOCATION: {
|
||||||
@@ -199,7 +196,7 @@ const legacy_decodeFromBackend = async ({
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const importFromBackend = async (
|
const importFromBackend = async (
|
||||||
id: string,
|
id: string,
|
||||||
decryptionKey: string,
|
decryptionKey: string,
|
||||||
): Promise<ImportedDataState> => {
|
): Promise<ImportedDataState> => {
|
||||||
@@ -241,6 +238,40 @@ export const importFromBackend = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const loadScene = async (
|
||||||
|
id: string | null,
|
||||||
|
privateKey: string | null,
|
||||||
|
// Supply local state even if importing from backend to ensure we restore
|
||||||
|
// localStorage user settings which we do not persist on server.
|
||||||
|
// Non-optional so we don't forget to pass it even if `undefined`.
|
||||||
|
localDataState: ImportedDataState | undefined | null,
|
||||||
|
) => {
|
||||||
|
let data;
|
||||||
|
if (id != null && privateKey != null) {
|
||||||
|
// the private key is used to decrypt the content from the server, take
|
||||||
|
// extra care not to leak it
|
||||||
|
data = restore(
|
||||||
|
await importFromBackend(id, privateKey),
|
||||||
|
localDataState?.appState,
|
||||||
|
localDataState?.elements,
|
||||||
|
{ repairBindings: true, refreshDimensions: false },
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
data = restore(localDataState || null, null, null, {
|
||||||
|
repairBindings: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
elements: data.elements,
|
||||||
|
appState: data.appState,
|
||||||
|
// note: this will always be empty because we're not storing files
|
||||||
|
// in the scene database/localStorage, and instead fetch them async
|
||||||
|
// from a different database
|
||||||
|
files: data.files,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
type ExportToBackendResult =
|
type ExportToBackendResult =
|
||||||
| { url: null; errorMessage: string }
|
| { url: null; errorMessage: string }
|
||||||
| { url: string; errorMessage: null };
|
| { url: string; errorMessage: null };
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
|
import type { ExcalidrawElement } from "@excalidraw/excalidraw/element/types";
|
||||||
|
import type { AppState } from "@excalidraw/excalidraw/types";
|
||||||
import {
|
import {
|
||||||
clearAppStateForLocalStorage,
|
clearAppStateForLocalStorage,
|
||||||
getDefaultAppState,
|
getDefaultAppState,
|
||||||
} from "@excalidraw/excalidraw/appState";
|
} from "@excalidraw/excalidraw/appState";
|
||||||
|
import { clearElementsForLocalStorage } from "@excalidraw/excalidraw/element";
|
||||||
import type { ExcalidrawElement } from "@excalidraw/element/types";
|
|
||||||
import type { AppState } from "@excalidraw/excalidraw/types";
|
|
||||||
|
|
||||||
import { STORAGE_KEYS } from "../app_constants";
|
import { STORAGE_KEYS } from "../app_constants";
|
||||||
|
|
||||||
export const saveUsernameToLocalStorage = (username: string) => {
|
export const saveUsernameToLocalStorage = (username: string) => {
|
||||||
@@ -49,7 +48,7 @@ export const importFromLocalStorage = () => {
|
|||||||
let elements: ExcalidrawElement[] = [];
|
let elements: ExcalidrawElement[] = [];
|
||||||
if (savedElements) {
|
if (savedElements) {
|
||||||
try {
|
try {
|
||||||
elements = JSON.parse(savedElements);
|
elements = clearElementsForLocalStorage(JSON.parse(savedElements));
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
// Do nothing because elements array is already empty
|
// Do nothing because elements array is already empty
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
debug: typeof Debug;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const lessPrecise = (num: number, precision = 5) =>
|
const lessPrecise = (num: number, precision = 5) =>
|
||||||
parseFloat(num.toPrecision(precision));
|
parseFloat(num.toPrecision(precision));
|
||||||
|
|
||||||
const getAvgFrameTime = (times: number[]) =>
|
const getAvgFrameTime = (times: number[]) =>
|
||||||
lessPrecise(times.reduce((a, b) => a + b) / times.length);
|
lessPrecise(times.reduce((a, b) => a + b) / times.length);
|
||||||
|
|
||||||
|
const getFps = (frametime: number) => lessPrecise(1000 / frametime);
|
||||||
|
|
||||||
export class Debug {
|
export class Debug {
|
||||||
public static DEBUG_LOG_TIMES = true;
|
public static DEBUG_LOG_TIMES = true;
|
||||||
|
|
||||||
@@ -16,35 +24,34 @@ export class Debug {
|
|||||||
private static LAST_DEBUG_LOG_CALL = 0;
|
private static LAST_DEBUG_LOG_CALL = 0;
|
||||||
private static DEBUG_LOG_INTERVAL_ID: null | number = null;
|
private static DEBUG_LOG_INTERVAL_ID: null | number = null;
|
||||||
|
|
||||||
private static LAST_FRAME_TIMESTAMP = 0;
|
|
||||||
private static FRAME_COUNT = 0;
|
|
||||||
private static ANIMATION_FRAME_ID: null | number = null;
|
|
||||||
|
|
||||||
private static scheduleAnimationFrame = () => {
|
|
||||||
if (Debug.DEBUG_LOG_INTERVAL_ID !== null) {
|
|
||||||
Debug.ANIMATION_FRAME_ID = requestAnimationFrame((timestamp) => {
|
|
||||||
if (Debug.LAST_FRAME_TIMESTAMP !== timestamp) {
|
|
||||||
Debug.LAST_FRAME_TIMESTAMP = timestamp;
|
|
||||||
Debug.FRAME_COUNT++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Debug.DEBUG_LOG_INTERVAL_ID !== null) {
|
|
||||||
Debug.scheduleAnimationFrame();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private static setupInterval = () => {
|
private static setupInterval = () => {
|
||||||
if (Debug.DEBUG_LOG_INTERVAL_ID === null) {
|
if (Debug.DEBUG_LOG_INTERVAL_ID === null) {
|
||||||
console.info("%c(starting perf recording)", "color: lime");
|
console.info("%c(starting perf recording)", "color: lime");
|
||||||
Debug.DEBUG_LOG_INTERVAL_ID = window.setInterval(Debug.debugLogger, 1000);
|
Debug.DEBUG_LOG_INTERVAL_ID = window.setInterval(Debug.debugLogger, 1000);
|
||||||
Debug.scheduleAnimationFrame();
|
|
||||||
}
|
}
|
||||||
Debug.LAST_DEBUG_LOG_CALL = Date.now();
|
Debug.LAST_DEBUG_LOG_CALL = Date.now();
|
||||||
};
|
};
|
||||||
|
|
||||||
private static debugLogger = () => {
|
private static debugLogger = () => {
|
||||||
|
if (
|
||||||
|
Date.now() - Debug.LAST_DEBUG_LOG_CALL > 600 &&
|
||||||
|
Debug.DEBUG_LOG_INTERVAL_ID !== null
|
||||||
|
) {
|
||||||
|
window.clearInterval(Debug.DEBUG_LOG_INTERVAL_ID);
|
||||||
|
Debug.DEBUG_LOG_INTERVAL_ID = null;
|
||||||
|
for (const [name, { avg }] of Object.entries(Debug.TIMES_AVG)) {
|
||||||
|
if (avg != null) {
|
||||||
|
console.info(
|
||||||
|
`%c${name} run avg: ${avg}ms (${getFps(avg)} fps)`,
|
||||||
|
"color: blue",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.info("%c(stopping perf recording)", "color: red");
|
||||||
|
Debug.TIMES_AGGR = {};
|
||||||
|
Debug.TIMES_AVG = {};
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Debug.DEBUG_LOG_TIMES) {
|
if (Debug.DEBUG_LOG_TIMES) {
|
||||||
for (const [name, { t, times }] of Object.entries(Debug.TIMES_AGGR)) {
|
for (const [name, { t, times }] of Object.entries(Debug.TIMES_AGGR)) {
|
||||||
if (times.length) {
|
if (times.length) {
|
||||||
@@ -58,18 +65,8 @@ export class Debug {
|
|||||||
}
|
}
|
||||||
for (const [name, { t, times, avg }] of Object.entries(Debug.TIMES_AVG)) {
|
for (const [name, { t, times, avg }] of Object.entries(Debug.TIMES_AVG)) {
|
||||||
if (times.length) {
|
if (times.length) {
|
||||||
// const avgFrameTime = getAvgFrameTime(times);
|
const avgFrameTime = getAvgFrameTime(times);
|
||||||
const totalTime = times.reduce((a, b) => a + b);
|
console.info(name, `${avgFrameTime}ms (${getFps(avgFrameTime)} fps)`);
|
||||||
const avgFrameTime = lessPrecise(totalTime / Debug.FRAME_COUNT);
|
|
||||||
console.info(
|
|
||||||
name,
|
|
||||||
`- ${times.length} calls - ${avgFrameTime}ms/frame across ${
|
|
||||||
Debug.FRAME_COUNT
|
|
||||||
} frames (${lessPrecise(
|
|
||||||
(avgFrameTime / 16.67) * 100,
|
|
||||||
1,
|
|
||||||
)}% of frame budget)`,
|
|
||||||
);
|
|
||||||
Debug.TIMES_AVG[name] = {
|
Debug.TIMES_AVG[name] = {
|
||||||
t,
|
t,
|
||||||
times: [],
|
times: [],
|
||||||
@@ -79,24 +76,6 @@ export class Debug {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Debug.FRAME_COUNT = 0;
|
|
||||||
|
|
||||||
// Check for stop condition after logging
|
|
||||||
if (
|
|
||||||
Date.now() - Debug.LAST_DEBUG_LOG_CALL > 600 &&
|
|
||||||
Debug.DEBUG_LOG_INTERVAL_ID !== null
|
|
||||||
) {
|
|
||||||
console.info("%c(stopping perf recording)", "color: red");
|
|
||||||
window.clearInterval(Debug.DEBUG_LOG_INTERVAL_ID);
|
|
||||||
window.cancelAnimationFrame(Debug.ANIMATION_FRAME_ID!);
|
|
||||||
Debug.ANIMATION_FRAME_ID = null;
|
|
||||||
Debug.FRAME_COUNT = 0;
|
|
||||||
Debug.LAST_FRAME_TIMESTAMP = 0;
|
|
||||||
|
|
||||||
Debug.DEBUG_LOG_INTERVAL_ID = null;
|
|
||||||
Debug.TIMES_AGGR = {};
|
|
||||||
Debug.TIMES_AVG = {};
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static logTime = (time?: number, name = "default") => {
|
public static logTime = (time?: number, name = "default") => {
|
||||||
@@ -130,7 +109,7 @@ export class Debug {
|
|||||||
return (...args: T) => {
|
return (...args: T) => {
|
||||||
const t0 = performance.now();
|
const t0 = performance.now();
|
||||||
const ret = fn(...args);
|
const ret = fn(...args);
|
||||||
Debug[type](performance.now() - t0, name);
|
Debug.logTime(performance.now() - t0, name);
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -151,70 +130,6 @@ export class Debug {
|
|||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
private static CHANGED_CACHE: Record<string, Record<string, unknown>> = {};
|
|
||||||
|
|
||||||
public static logChanged(name: string, obj: Record<string, unknown>) {
|
|
||||||
const prev = Debug.CHANGED_CACHE[name];
|
|
||||||
|
|
||||||
Debug.CHANGED_CACHE[name] = obj;
|
|
||||||
|
|
||||||
if (!prev) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const allKeys = new Set([...Object.keys(prev), ...Object.keys(obj)]);
|
|
||||||
const changed: Record<string, { prev: unknown; next: unknown }> = {};
|
|
||||||
|
|
||||||
for (const key of allKeys) {
|
|
||||||
const prevVal = prev[key];
|
|
||||||
const nextVal = obj[key];
|
|
||||||
if (!deepEqual(prevVal, nextVal)) {
|
|
||||||
changed[key] = { prev: prevVal, next: nextVal };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Object.keys(changed).length > 0) {
|
|
||||||
console.info(`[${name}] changed:`, changed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function deepEqual(a: unknown, b: unknown): boolean {
|
|
||||||
if (Object.is(a, b)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
a === null ||
|
|
||||||
b === null ||
|
|
||||||
typeof a !== "object" ||
|
|
||||||
typeof b !== "object"
|
|
||||||
) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(a) !== Array.isArray(b)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const keysA = Object.keys(a as Record<string, unknown>);
|
|
||||||
const keysB = Object.keys(b as Record<string, unknown>);
|
|
||||||
|
|
||||||
if (keysA.length !== keysB.length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const key of keysA) {
|
|
||||||
if (
|
|
||||||
!deepEqual(
|
|
||||||
(a as Record<string, unknown>)[key],
|
|
||||||
(b as Record<string, unknown>)[key],
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
//@ts-ignore
|
||||||
|
window.debug = Debug;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title>Excalidraw Whiteboard</title>
|
<title>Excalidraw | Hand-drawn look & feel • Collaborative • Secure</title>
|
||||||
<meta
|
<meta
|
||||||
name="viewport"
|
name="viewport"
|
||||||
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover, shrink-to-fit=no"
|
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover, shrink-to-fit=no"
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<!-- Primary Meta Tags -->
|
<!-- Primary Meta Tags -->
|
||||||
<meta
|
<meta
|
||||||
name="title"
|
name="title"
|
||||||
content="Free, collaborative whiteboard • Hand-drawn look & feel | Excalidraw"
|
content="Excalidraw — Collaborative whiteboarding made easy"
|
||||||
/>
|
/>
|
||||||
<meta
|
<meta
|
||||||
name="description"
|
name="description"
|
||||||
|
|||||||
+14
-27
@@ -1,5 +1,3 @@
|
|||||||
@import "../packages/excalidraw/css/variables.module.scss";
|
|
||||||
|
|
||||||
.excalidraw {
|
.excalidraw {
|
||||||
--color-primary-contrast-offset: #625ee0; // to offset Chubb illusion
|
--color-primary-contrast-offset: #625ee0; // to offset Chubb illusion
|
||||||
|
|
||||||
@@ -7,6 +5,12 @@
|
|||||||
--color-primary-contrast-offset: #726dff; // to offset Chubb illusion
|
--color-primary-contrast-offset: #726dff; // to offset Chubb illusion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.top-right-ui {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
.footer-center {
|
.footer-center {
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
@@ -54,7 +58,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert {
|
.collab-offline-warning {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 6.5rem;
|
top: 6.5rem;
|
||||||
@@ -65,18 +69,10 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
border-radius: var(--border-radius-md);
|
border-radius: var(--border-radius-md);
|
||||||
|
background-color: var(--color-warning);
|
||||||
|
color: var(--color-text-warning);
|
||||||
z-index: 6;
|
z-index: 6;
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
|
|
||||||
&--warning {
|
|
||||||
background-color: var(--color-warning);
|
|
||||||
color: var(--color-text-warning);
|
|
||||||
}
|
|
||||||
|
|
||||||
&--danger {
|
|
||||||
background-color: var(--color-danger-dark);
|
|
||||||
color: var(--color-danger-text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,31 +82,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.plus-banner {
|
.plus-button {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border: 1px solid var(--color-primary);
|
border: 1px solid var(--color-primary);
|
||||||
padding: 0.5rem 0.875rem;
|
padding: 0.5rem 0.75rem;
|
||||||
border-radius: var(--border-radius-lg);
|
border-radius: var(--border-radius-lg);
|
||||||
background-color: var(--island-bg-color);
|
background-color: var(--island-bg-color);
|
||||||
|
color: var(--color-primary) !important;
|
||||||
text-decoration: none !important;
|
text-decoration: none !important;
|
||||||
|
|
||||||
font-family: var(--ui-font);
|
font-size: 0.75rem;
|
||||||
font-size: 0.8333rem;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
height: var(--lg-button-size);
|
height: var(--lg-button-size);
|
||||||
|
|
||||||
border: none;
|
|
||||||
box-shadow: 0 0 0 1px var(--color-surface-lowest);
|
|
||||||
background-color: var(--color-surface-low);
|
|
||||||
color: var(--button-color, var(--color-on-surface)) !important;
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
box-shadow: 0 0 0 1px var(--color-brand-active);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: var(--color-primary);
|
background-color: var(--color-primary);
|
||||||
color: white !important;
|
color: white !important;
|
||||||
@@ -122,7 +109,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.theme--dark {
|
.theme--dark {
|
||||||
.plus-banner {
|
.plus-button {
|
||||||
&:hover {
|
&:hover {
|
||||||
color: black !important;
|
color: black !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import { StrictMode } from "react";
|
import { StrictMode } from "react";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
|
import ExcalidrawApp from "./App";
|
||||||
import { registerSW } from "virtual:pwa-register";
|
import { registerSW } from "virtual:pwa-register";
|
||||||
|
|
||||||
import "../excalidraw-app/sentry";
|
import "../excalidraw-app/sentry";
|
||||||
|
|
||||||
import ExcalidrawApp from "./App";
|
|
||||||
|
|
||||||
window.__EXCALIDRAW_SHA__ = import.meta.env.VITE_APP_GIT_SHA;
|
window.__EXCALIDRAW_SHA__ = import.meta.env.VITE_APP_GIT_SHA;
|
||||||
const rootElement = document.getElementById("root")!;
|
const rootElement = document.getElementById("root")!;
|
||||||
const root = createRoot(rootElement);
|
const root = createRoot(rootElement);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0"
|
"node": "18.0.0 - 22.x.x"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@excalidraw/random-username": "1.0.0",
|
"@excalidraw/random-username": "1.0.0",
|
||||||
@@ -36,7 +36,6 @@
|
|||||||
"react": "19.0.0",
|
"react": "19.0.0",
|
||||||
"react-dom": "19.0.0",
|
"react-dom": "19.0.0",
|
||||||
"socket.io-client": "4.7.2",
|
"socket.io-client": "4.7.2",
|
||||||
"uqr": "0.1.2",
|
|
||||||
"vite-plugin-html": "3.2.2"
|
"vite-plugin-html": "3.2.2"
|
||||||
},
|
},
|
||||||
"prettier": "@excalidraw/prettier-config",
|
"prettier": "@excalidraw/prettier-config",
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { getFeatureFlag } from "@excalidraw/common";
|
|
||||||
import * as Sentry from "@sentry/browser";
|
import * as Sentry from "@sentry/browser";
|
||||||
import callsites from "callsites";
|
import callsites from "callsites";
|
||||||
|
|
||||||
@@ -34,7 +33,6 @@ Sentry.init({
|
|||||||
Sentry.captureConsoleIntegration({
|
Sentry.captureConsoleIntegration({
|
||||||
levels: ["error"],
|
levels: ["error"],
|
||||||
}),
|
}),
|
||||||
Sentry.featureFlagsIntegration(),
|
|
||||||
],
|
],
|
||||||
beforeSend(event) {
|
beforeSend(event) {
|
||||||
if (event.request?.url) {
|
if (event.request?.url) {
|
||||||
@@ -81,14 +79,3 @@ Sentry.init({
|
|||||||
return event;
|
return event;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const flagsIntegration =
|
|
||||||
Sentry.getClient()?.getIntegrationByName<Sentry.FeatureFlagsIntegration>(
|
|
||||||
"FeatureFlags",
|
|
||||||
);
|
|
||||||
if (flagsIntegration) {
|
|
||||||
flagsIntegration.addFeatureFlag(
|
|
||||||
"COMPLEX_BINDINGS",
|
|
||||||
getFeatureFlag("COMPLEX_BINDINGS"),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
import { useEffect, useState } from "react";
|
|
||||||
import Spinner from "@excalidraw/excalidraw/components/Spinner";
|
|
||||||
|
|
||||||
interface QRCodeProps {
|
|
||||||
value: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const QRCode = ({ value }: QRCodeProps) => {
|
|
||||||
const [svgData, setSvgData] = useState<string | null>(null);
|
|
||||||
const [error, setError] = useState<boolean>(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let mounted = true;
|
|
||||||
|
|
||||||
import("./qrcode.chunk")
|
|
||||||
.then(({ generateQRCodeSVG }) => {
|
|
||||||
if (mounted) {
|
|
||||||
try {
|
|
||||||
setSvgData(generateQRCodeSVG(value));
|
|
||||||
} catch {
|
|
||||||
setError(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
if (mounted) {
|
|
||||||
setError(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
mounted = false;
|
|
||||||
};
|
|
||||||
}, [value]);
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!svgData) {
|
|
||||||
return (
|
|
||||||
<div className="ShareDialog__active__qrcode ShareDialog__active__qrcode--loading">
|
|
||||||
<Spinner />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="ShareDialog__active__qrcode"
|
|
||||||
role="img"
|
|
||||||
aria-label="QR code for collaboration link"
|
|
||||||
dangerouslySetInnerHTML={{ __html: svgData }}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -140,31 +140,6 @@
|
|||||||
gap: 0.75rem;
|
gap: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__qrcode {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
align-self: center;
|
|
||||||
padding: 1rem;
|
|
||||||
background: #fff;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
border: 1px solid #e0e0e0;
|
|
||||||
|
|
||||||
$size: 150px;
|
|
||||||
width: $size;
|
|
||||||
height: $size;
|
|
||||||
|
|
||||||
& svg {
|
|
||||||
width: $size;
|
|
||||||
height: $size;
|
|
||||||
}
|
|
||||||
|
|
||||||
&--loading {
|
|
||||||
background: var(--island-bg-color);
|
|
||||||
border: 1px solid var(--dialog-border-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&__description {
|
&__description {
|
||||||
border-top: 1px solid var(--color-gray-20);
|
border-top: 1px solid var(--color-gray-20);
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { trackEvent } from "@excalidraw/excalidraw/analytics";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { copyTextToSystemClipboard } from "@excalidraw/excalidraw/clipboard";
|
import { copyTextToSystemClipboard } from "@excalidraw/excalidraw/clipboard";
|
||||||
|
import { trackEvent } from "@excalidraw/excalidraw/analytics";
|
||||||
|
import { getFrame } from "@excalidraw/excalidraw/utils";
|
||||||
|
import { useI18n } from "@excalidraw/excalidraw/i18n";
|
||||||
|
import { KEYS } from "@excalidraw/excalidraw/keys";
|
||||||
import { Dialog } from "@excalidraw/excalidraw/components/Dialog";
|
import { Dialog } from "@excalidraw/excalidraw/components/Dialog";
|
||||||
import { FilledButton } from "@excalidraw/excalidraw/components/FilledButton";
|
|
||||||
import { TextField } from "@excalidraw/excalidraw/components/TextField";
|
|
||||||
import {
|
import {
|
||||||
copyIcon,
|
copyIcon,
|
||||||
LinkIcon,
|
LinkIcon,
|
||||||
@@ -12,19 +14,15 @@ import {
|
|||||||
shareIOS,
|
shareIOS,
|
||||||
shareWindows,
|
shareWindows,
|
||||||
} from "@excalidraw/excalidraw/components/icons";
|
} from "@excalidraw/excalidraw/components/icons";
|
||||||
|
import { TextField } from "@excalidraw/excalidraw/components/TextField";
|
||||||
|
import { FilledButton } from "@excalidraw/excalidraw/components/FilledButton";
|
||||||
|
import type { CollabAPI } from "../collab/Collab";
|
||||||
|
import { activeRoomLinkAtom } from "../collab/Collab";
|
||||||
import { useUIAppState } from "@excalidraw/excalidraw/context/ui-appState";
|
import { useUIAppState } from "@excalidraw/excalidraw/context/ui-appState";
|
||||||
import { useCopyStatus } from "@excalidraw/excalidraw/hooks/useCopiedIndicator";
|
import { useCopyStatus } from "@excalidraw/excalidraw/hooks/useCopiedIndicator";
|
||||||
import { useI18n } from "@excalidraw/excalidraw/i18n";
|
|
||||||
import { KEYS, getFrame } from "@excalidraw/common";
|
|
||||||
import { useEffect, useRef, useState } from "react";
|
|
||||||
|
|
||||||
import { atom, useAtom, useAtomValue } from "../app-jotai";
|
import { atom, useAtom, useAtomValue } from "../app-jotai";
|
||||||
import { activeRoomLinkAtom } from "../collab/Collab";
|
|
||||||
|
|
||||||
import "./ShareDialog.scss";
|
import "./ShareDialog.scss";
|
||||||
import { QRCode } from "./QRCode";
|
|
||||||
|
|
||||||
import type { CollabAPI } from "../collab/Collab";
|
|
||||||
|
|
||||||
type OnExportToBackend = () => void;
|
type OnExportToBackend = () => void;
|
||||||
type ShareDialogType = "share" | "collaborationOnly";
|
type ShareDialogType = "share" | "collaborationOnly";
|
||||||
@@ -143,7 +141,6 @@ const ActiveRoomDialog = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<QRCode value={activeRoomLink} />
|
|
||||||
<div className="ShareDialog__active__description">
|
<div className="ShareDialog__active__description">
|
||||||
<p>
|
<p>
|
||||||
<span
|
<span
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
import { renderSVG } from "uqr";
|
|
||||||
|
|
||||||
export const generateQRCodeSVG = (text: string): string => {
|
|
||||||
return renderSVG(text);
|
|
||||||
};
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import { UI } from "@excalidraw/excalidraw/tests/helpers/ui";
|
import ExcalidrawApp from "../App";
|
||||||
import {
|
import {
|
||||||
mockBoundingClientRect,
|
mockBoundingClientRect,
|
||||||
render,
|
render,
|
||||||
restoreOriginalGetBoundingClientRect,
|
restoreOriginalGetBoundingClientRect,
|
||||||
} from "@excalidraw/excalidraw/tests/test-utils";
|
} from "@excalidraw/excalidraw/tests/test-utils";
|
||||||
|
|
||||||
import ExcalidrawApp from "../App";
|
import { UI } from "@excalidraw/excalidraw/tests/helpers/ui";
|
||||||
|
|
||||||
describe("Test MobileMenu", () => {
|
describe("Test MobileMenu", () => {
|
||||||
const { h } = window;
|
const { h } = window;
|
||||||
@@ -17,15 +17,30 @@ describe("Test MobileMenu", () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await render(<ExcalidrawApp />);
|
await render(<ExcalidrawApp />);
|
||||||
h.app.refreshEditorInterface();
|
// @ts-ignore
|
||||||
|
h.app.refreshViewportBreakpoints();
|
||||||
|
// @ts-ignore
|
||||||
|
h.app.refreshEditorBreakpoints();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
restoreOriginalGetBoundingClientRect();
|
restoreOriginalGetBoundingClientRect();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should set editor interface correctly", () => {
|
it("should set device correctly", () => {
|
||||||
expect(h.app.editorInterface.formFactor).toBe("phone");
|
expect(h.app.device).toMatchInlineSnapshot(`
|
||||||
|
{
|
||||||
|
"editor": {
|
||||||
|
"canFitSidebar": false,
|
||||||
|
"isMobile": true,
|
||||||
|
},
|
||||||
|
"isTouchScreen": false,
|
||||||
|
"viewport": {
|
||||||
|
"isLandscape": false,
|
||||||
|
"isMobile": true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should initialize with welcome screen and hide once user interacts", async () => {
|
it("should initialize with welcome screen and hide once user interacts", async () => {
|
||||||
|
|||||||
@@ -50,11 +50,7 @@ exports[`Test MobileMenu > should initialize with welcome screen and hide once u
|
|||||||
<div
|
<div
|
||||||
class="welcome-screen-center__heading welcome-screen-decor excalifont"
|
class="welcome-screen-center__heading welcome-screen-decor excalifont"
|
||||||
>
|
>
|
||||||
Your drawings are saved in your browser's storage.
|
All your data is saved locally in your browser.
|
||||||
<br />
|
|
||||||
Browser storage can be cleared unexpectedly.
|
|
||||||
<br />
|
|
||||||
Save your work to a file regularly to avoid losing it.
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="welcome-screen-menu"
|
class="welcome-screen-menu"
|
||||||
@@ -202,7 +198,7 @@ exports[`Test MobileMenu > should initialize with welcome screen and hide once u
|
|||||||
<a
|
<a
|
||||||
class="welcome-screen-menu-item "
|
class="welcome-screen-menu-item "
|
||||||
href="undefined/plus?utm_source=excalidraw&utm_medium=app&utm_content=welcomeScreenGuest"
|
href="undefined/plus?utm_source=excalidraw&utm_medium=app&utm_content=welcomeScreenGuest"
|
||||||
rel="noopener"
|
rel="noreferrer"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
import { CaptureUpdateAction, newElementWith } from "@excalidraw/excalidraw";
|
import { vi } from "vitest";
|
||||||
|
import { act, render, waitFor } from "@excalidraw/excalidraw/tests/test-utils";
|
||||||
|
import ExcalidrawApp from "../App";
|
||||||
|
import { API } from "@excalidraw/excalidraw/tests/helpers/api";
|
||||||
|
import { syncInvalidIndices } from "@excalidraw/excalidraw/fractionalIndex";
|
||||||
import {
|
import {
|
||||||
createRedoAction,
|
createRedoAction,
|
||||||
createUndoAction,
|
createUndoAction,
|
||||||
} from "@excalidraw/excalidraw/actions/actionHistory";
|
} from "@excalidraw/excalidraw/actions/actionHistory";
|
||||||
import { syncInvalidIndices } from "@excalidraw/element";
|
import { CaptureUpdateAction, newElementWith } from "@excalidraw/excalidraw";
|
||||||
import { API } from "@excalidraw/excalidraw/tests/helpers/api";
|
|
||||||
import { act, render, waitFor } from "@excalidraw/excalidraw/tests/test-utils";
|
|
||||||
import { vi } from "vitest";
|
|
||||||
|
|
||||||
import { StoreIncrement } from "@excalidraw/element";
|
|
||||||
|
|
||||||
import type { DurableIncrement, EphemeralIncrement } from "@excalidraw/element";
|
|
||||||
|
|
||||||
import ExcalidrawApp from "../App";
|
|
||||||
|
|
||||||
const { h } = window;
|
const { h } = window;
|
||||||
|
|
||||||
@@ -69,79 +64,6 @@ vi.mock("socket.io-client", () => {
|
|||||||
* i.e. multiplayer history tests could be a good first candidate, as we could test both history stacks simultaneously.
|
* i.e. multiplayer history tests could be a good first candidate, as we could test both history stacks simultaneously.
|
||||||
*/
|
*/
|
||||||
describe("collaboration", () => {
|
describe("collaboration", () => {
|
||||||
it("should emit two ephemeral increments even though updates get batched", async () => {
|
|
||||||
const durableIncrements: DurableIncrement[] = [];
|
|
||||||
const ephemeralIncrements: EphemeralIncrement[] = [];
|
|
||||||
|
|
||||||
await render(<ExcalidrawApp />);
|
|
||||||
|
|
||||||
h.store.onStoreIncrementEmitter.on((increment) => {
|
|
||||||
if (StoreIncrement.isDurable(increment)) {
|
|
||||||
durableIncrements.push(increment);
|
|
||||||
} else {
|
|
||||||
ephemeralIncrements.push(increment);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// eslint-disable-next-line dot-notation
|
|
||||||
expect(h.store["scheduledMicroActions"].length).toBe(0);
|
|
||||||
expect(durableIncrements.length).toBe(0);
|
|
||||||
expect(ephemeralIncrements.length).toBe(0);
|
|
||||||
|
|
||||||
const rectProps = {
|
|
||||||
type: "rectangle",
|
|
||||||
id: "A",
|
|
||||||
height: 200,
|
|
||||||
width: 100,
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
const rect = API.createElement({ ...rectProps });
|
|
||||||
|
|
||||||
API.updateScene({
|
|
||||||
elements: [rect],
|
|
||||||
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
|
|
||||||
});
|
|
||||||
|
|
||||||
await waitFor(() => {
|
|
||||||
// expect(commitSpy).toHaveBeenCalledTimes(1);
|
|
||||||
expect(durableIncrements.length).toBe(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
// simulate two batched remote updates
|
|
||||||
act(() => {
|
|
||||||
h.app.updateScene({
|
|
||||||
elements: [newElementWith(h.elements[0], { x: 100 })],
|
|
||||||
captureUpdate: CaptureUpdateAction.NEVER,
|
|
||||||
});
|
|
||||||
h.app.updateScene({
|
|
||||||
elements: [newElementWith(h.elements[0], { x: 200 })],
|
|
||||||
captureUpdate: CaptureUpdateAction.NEVER,
|
|
||||||
});
|
|
||||||
|
|
||||||
// we scheduled two micro actions,
|
|
||||||
// which confirms they are going to be executed as part of one batched component update
|
|
||||||
// eslint-disable-next-line dot-notation
|
|
||||||
expect(h.store["scheduledMicroActions"].length).toBe(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
await waitFor(() => {
|
|
||||||
// altough the updates get batched,
|
|
||||||
// we expect two ephemeral increments for each update,
|
|
||||||
// and each such update should have the expected change
|
|
||||||
expect(ephemeralIncrements.length).toBe(2);
|
|
||||||
expect(ephemeralIncrements[0].change.elements.A).toEqual(
|
|
||||||
expect.objectContaining({ x: 100 }),
|
|
||||||
);
|
|
||||||
expect(ephemeralIncrements[1].change.elements.A).toEqual(
|
|
||||||
expect.objectContaining({ x: 200 }),
|
|
||||||
);
|
|
||||||
// eslint-disable-next-line dot-notation
|
|
||||||
expect(h.store["scheduledMicroActions"].length).toBe(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should allow to undo / redo even on force-deleted elements", async () => {
|
it("should allow to undo / redo even on force-deleted elements", async () => {
|
||||||
await render(<ExcalidrawApp />);
|
await render(<ExcalidrawApp />);
|
||||||
const rect1Props = {
|
const rect1Props = {
|
||||||
@@ -199,13 +121,12 @@ describe("collaboration", () => {
|
|||||||
expect(h.elements).toEqual([expect.objectContaining(rect1Props)]);
|
expect(h.elements).toEqual([expect.objectContaining(rect1Props)]);
|
||||||
});
|
});
|
||||||
|
|
||||||
const undoAction = createUndoAction(h.history);
|
const undoAction = createUndoAction(h.history, h.store);
|
||||||
act(() => h.app.actionManager.executeAction(undoAction));
|
act(() => h.app.actionManager.executeAction(undoAction));
|
||||||
|
|
||||||
// with explicit undo (as addition) we expect our item to be restored from the snapshot!
|
// with explicit undo (as addition) we expect our item to be restored from the snapshot!
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(API.getUndoStack().length).toBe(1);
|
expect(API.getUndoStack().length).toBe(1);
|
||||||
expect(API.getRedoStack().length).toBe(1);
|
|
||||||
expect(API.getSnapshot()).toEqual([
|
expect(API.getSnapshot()).toEqual([
|
||||||
expect.objectContaining(rect1Props),
|
expect.objectContaining(rect1Props),
|
||||||
expect.objectContaining({ ...rect2Props, isDeleted: false }),
|
expect.objectContaining({ ...rect2Props, isDeleted: false }),
|
||||||
@@ -232,7 +153,7 @@ describe("collaboration", () => {
|
|||||||
expect(h.elements).toEqual([expect.objectContaining(rect1Props)]);
|
expect(h.elements).toEqual([expect.objectContaining(rect1Props)]);
|
||||||
});
|
});
|
||||||
|
|
||||||
const redoAction = createRedoAction(h.history);
|
const redoAction = createRedoAction(h.history, h.store);
|
||||||
act(() => h.app.actionManager.executeAction(redoAction));
|
act(() => h.app.actionManager.executeAction(redoAction));
|
||||||
|
|
||||||
// with explicit redo (as removal) we again restore the element from the snapshot!
|
// with explicit redo (as removal) we again restore the element from the snapshot!
|
||||||
@@ -248,5 +169,79 @@ describe("collaboration", () => {
|
|||||||
expect.objectContaining({ ...rect2Props, isDeleted: true }),
|
expect.objectContaining({ ...rect2Props, isDeleted: true }),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
act(() => h.app.actionManager.executeAction(undoAction));
|
||||||
|
|
||||||
|
// simulate local update
|
||||||
|
API.updateScene({
|
||||||
|
elements: syncInvalidIndices([
|
||||||
|
h.elements[0],
|
||||||
|
newElementWith(h.elements[1], { x: 100 }),
|
||||||
|
]),
|
||||||
|
captureUpdate: CaptureUpdateAction.IMMEDIATELY,
|
||||||
|
});
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(API.getUndoStack().length).toBe(2);
|
||||||
|
expect(API.getRedoStack().length).toBe(0);
|
||||||
|
expect(API.getSnapshot()).toEqual([
|
||||||
|
expect.objectContaining(rect1Props),
|
||||||
|
expect.objectContaining({ ...rect2Props, isDeleted: false, x: 100 }),
|
||||||
|
]);
|
||||||
|
expect(h.elements).toEqual([
|
||||||
|
expect.objectContaining(rect1Props),
|
||||||
|
expect.objectContaining({ ...rect2Props, isDeleted: false, x: 100 }),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
act(() => h.app.actionManager.executeAction(undoAction));
|
||||||
|
|
||||||
|
// we expect to iterate the stack to the first visible change
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(API.getUndoStack().length).toBe(1);
|
||||||
|
expect(API.getRedoStack().length).toBe(1);
|
||||||
|
expect(API.getSnapshot()).toEqual([
|
||||||
|
expect.objectContaining(rect1Props),
|
||||||
|
expect.objectContaining({ ...rect2Props, isDeleted: false, x: 0 }),
|
||||||
|
]);
|
||||||
|
expect(h.elements).toEqual([
|
||||||
|
expect.objectContaining(rect1Props),
|
||||||
|
expect.objectContaining({ ...rect2Props, isDeleted: false, x: 0 }),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
// simulate force deleting the element remotely
|
||||||
|
API.updateScene({
|
||||||
|
elements: syncInvalidIndices([rect1]),
|
||||||
|
captureUpdate: CaptureUpdateAction.NEVER,
|
||||||
|
});
|
||||||
|
|
||||||
|
// snapshot was correctly updated and marked the element as deleted
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(API.getUndoStack().length).toBe(1);
|
||||||
|
expect(API.getRedoStack().length).toBe(1);
|
||||||
|
expect(API.getSnapshot()).toEqual([
|
||||||
|
expect.objectContaining(rect1Props),
|
||||||
|
expect.objectContaining({ ...rect2Props, isDeleted: true, x: 0 }),
|
||||||
|
]);
|
||||||
|
expect(h.elements).toEqual([expect.objectContaining(rect1Props)]);
|
||||||
|
});
|
||||||
|
|
||||||
|
act(() => h.app.actionManager.executeAction(redoAction));
|
||||||
|
|
||||||
|
// with explicit redo (as update) we again restored the element from the snapshot!
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(API.getUndoStack().length).toBe(2);
|
||||||
|
expect(API.getRedoStack().length).toBe(0);
|
||||||
|
expect(API.getSnapshot()).toEqual([
|
||||||
|
expect.objectContaining({ id: "A", isDeleted: false }),
|
||||||
|
expect.objectContaining({ id: "B", isDeleted: true, x: 100 }),
|
||||||
|
]);
|
||||||
|
expect(h.history.isRedoStackEmpty).toBeTruthy();
|
||||||
|
expect(h.elements).toEqual([
|
||||||
|
expect.objectContaining({ id: "A", isDeleted: false }),
|
||||||
|
expect.objectContaining({ id: "B", isDeleted: true, x: 100 }),
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { THEME } from "@excalidraw/excalidraw";
|
|
||||||
import { EVENT, CODES, KEYS } from "@excalidraw/common";
|
|
||||||
import { useEffect, useLayoutEffect, useState } from "react";
|
import { useEffect, useLayoutEffect, useState } from "react";
|
||||||
|
import { THEME } from "@excalidraw/excalidraw";
|
||||||
import type { Theme } from "@excalidraw/element/types";
|
import { EVENT } from "@excalidraw/excalidraw/constants";
|
||||||
|
import type { Theme } from "@excalidraw/excalidraw/element/types";
|
||||||
|
import { CODES, KEYS } from "@excalidraw/excalidraw/keys";
|
||||||
import { STORAGE_KEYS } from "./app_constants";
|
import { STORAGE_KEYS } from "./app_constants";
|
||||||
|
|
||||||
const getDarkThemeMediaQuery = (): MediaQueryList | undefined =>
|
const getDarkThemeMediaQuery = (): MediaQueryList | undefined =>
|
||||||
|
|||||||
@@ -23,57 +23,29 @@ export default defineConfig(({ mode }) => {
|
|||||||
envDir: "../",
|
envDir: "../",
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: [
|
alias: [
|
||||||
{
|
|
||||||
find: /^@excalidraw\/common$/,
|
|
||||||
replacement: path.resolve(
|
|
||||||
__dirname,
|
|
||||||
"../packages/common/src/index.ts",
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
find: /^@excalidraw\/common\/(.*?)/,
|
|
||||||
replacement: path.resolve(__dirname, "../packages/common/src/$1"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
find: /^@excalidraw\/element$/,
|
|
||||||
replacement: path.resolve(
|
|
||||||
__dirname,
|
|
||||||
"../packages/element/src/index.ts",
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
find: /^@excalidraw\/element\/(.*?)/,
|
|
||||||
replacement: path.resolve(__dirname, "../packages/element/src/$1"),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: /^@excalidraw\/excalidraw$/,
|
find: /^@excalidraw\/excalidraw$/,
|
||||||
replacement: path.resolve(
|
replacement: path.resolve(__dirname, "../packages/excalidraw/index.tsx"),
|
||||||
__dirname,
|
|
||||||
"../packages/excalidraw/index.tsx",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: /^@excalidraw\/excalidraw\/(.*?)/,
|
find: /^@excalidraw\/excalidraw\/(.*?)/,
|
||||||
replacement: path.resolve(__dirname, "../packages/excalidraw/$1"),
|
replacement: path.resolve(__dirname, "../packages/excalidraw/$1"),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
find: /^@excalidraw\/math$/,
|
|
||||||
replacement: path.resolve(__dirname, "../packages/math/src/index.ts"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
find: /^@excalidraw\/math\/(.*?)/,
|
|
||||||
replacement: path.resolve(__dirname, "../packages/math/src/$1"),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
find: /^@excalidraw\/utils$/,
|
find: /^@excalidraw\/utils$/,
|
||||||
replacement: path.resolve(
|
replacement: path.resolve(__dirname, "../packages/utils/index.ts"),
|
||||||
__dirname,
|
|
||||||
"../packages/utils/src/index.ts",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: /^@excalidraw\/utils\/(.*?)/,
|
find: /^@excalidraw\/utils\/(.*?)/,
|
||||||
replacement: path.resolve(__dirname, "../packages/utils/src/$1"),
|
replacement: path.resolve(__dirname, "../packages/utils/$1"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: /^@excalidraw\/math$/,
|
||||||
|
replacement: path.resolve(__dirname, "../packages/math/index.ts"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: /^@excalidraw\/math\/(.*?)/,
|
||||||
|
replacement: path.resolve(__dirname, "../packages/math/$1"),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -102,14 +74,6 @@ export default defineConfig(({ mode }) => {
|
|||||||
// Taking the substring after "locales/"
|
// Taking the substring after "locales/"
|
||||||
return `locales/${id.substring(index + 8)}`;
|
return `locales/${id.substring(index + 8)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id.includes("@excalidraw/mermaid-to-excalidraw")) {
|
|
||||||
return "mermaid-to-excalidraw";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (id.includes("@codemirror/") || id.includes("@lezer/")) {
|
|
||||||
return "codemirror.chunk";
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -154,11 +118,6 @@ export default defineConfig(({ mode }) => {
|
|||||||
"**/locales/**",
|
"**/locales/**",
|
||||||
"service-worker.js",
|
"service-worker.js",
|
||||||
"**/*.chunk-*.js",
|
"**/*.chunk-*.js",
|
||||||
// CodeMirrorEditor can't be assigned a `.chunk` name via
|
|
||||||
// manualChunks because Rollup would hoist shared deps (React)
|
|
||||||
// via a static import from the main bundle, defeating lazy
|
|
||||||
// loading. So we exclude it by name instead.
|
|
||||||
"**/CodeMirrorEditor-*.js",
|
|
||||||
],
|
],
|
||||||
runtimeCaching: [
|
runtimeCaching: [
|
||||||
{
|
{
|
||||||
@@ -198,7 +157,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
urlPattern: new RegExp("(.chunk-.+|CodeMirrorEditor-.+)\\.js"),
|
urlPattern: new RegExp(".chunk-.+.js"),
|
||||||
handler: "CacheFirst",
|
handler: "CacheFirst",
|
||||||
options: {
|
options: {
|
||||||
cacheName: "chunk",
|
cacheName: "chunk",
|
||||||
@@ -209,7 +168,6 @@ export default defineConfig(({ mode }) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
maximumFileSizeToCacheInBytes: 2.3 * 1024 ** 2, // 2.3MB
|
|
||||||
},
|
},
|
||||||
manifest: {
|
manifest: {
|
||||||
short_name: "Excalidraw",
|
short_name: "Excalidraw",
|
||||||
@@ -239,7 +197,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
start_url: "/",
|
start_url: "/",
|
||||||
id: "excalidraw",
|
id:"excalidraw",
|
||||||
display: "standalone",
|
display: "standalone",
|
||||||
theme_color: "#121212",
|
theme_color: "#121212",
|
||||||
background_color: "#ffffff",
|
background_color: "#ffffff",
|
||||||
|
|||||||
+12
-17
@@ -4,7 +4,9 @@
|
|||||||
"packageManager": "yarn@1.22.22",
|
"packageManager": "yarn@1.22.22",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"excalidraw-app",
|
"excalidraw-app",
|
||||||
"packages/*",
|
"packages/excalidraw",
|
||||||
|
"packages/utils",
|
||||||
|
"packages/math",
|
||||||
"examples/*"
|
"examples/*"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -24,7 +26,6 @@
|
|||||||
"dotenv": "16.0.1",
|
"dotenv": "16.0.1",
|
||||||
"eslint-config-prettier": "8.5.0",
|
"eslint-config-prettier": "8.5.0",
|
||||||
"eslint-config-react-app": "7.0.1",
|
"eslint-config-react-app": "7.0.1",
|
||||||
"eslint-plugin-import": "2.31.0",
|
|
||||||
"eslint-plugin-prettier": "3.3.1",
|
"eslint-plugin-prettier": "3.3.1",
|
||||||
"http-server": "14.1.1",
|
"http-server": "14.1.1",
|
||||||
"husky": "7.0.4",
|
"husky": "7.0.4",
|
||||||
@@ -33,8 +34,7 @@
|
|||||||
"pepjs": "0.5.3",
|
"pepjs": "0.5.3",
|
||||||
"prettier": "2.6.2",
|
"prettier": "2.6.2",
|
||||||
"rewire": "6.0.0",
|
"rewire": "6.0.0",
|
||||||
"rimraf": "^5.0.0",
|
"typescript": "4.9.4",
|
||||||
"typescript": "5.9.3",
|
|
||||||
"vite": "5.0.12",
|
"vite": "5.0.12",
|
||||||
"vite-plugin-checker": "0.7.2",
|
"vite-plugin-checker": "0.7.2",
|
||||||
"vite-plugin-ejs": "1.7.0",
|
"vite-plugin-ejs": "1.7.0",
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
"vitest-canvas-mock": "0.3.3"
|
"vitest-canvas-mock": "0.3.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0"
|
"node": "18.0.0 - 22.x.x"
|
||||||
},
|
},
|
||||||
"homepage": ".",
|
"homepage": ".",
|
||||||
"prettier": "@excalidraw/prettier-config",
|
"prettier": "@excalidraw/prettier-config",
|
||||||
@@ -52,17 +52,13 @@
|
|||||||
"build-node": "node ./scripts/build-node.js",
|
"build-node": "node ./scripts/build-node.js",
|
||||||
"build:app:docker": "yarn --cwd ./excalidraw-app build:app:docker",
|
"build:app:docker": "yarn --cwd ./excalidraw-app build:app:docker",
|
||||||
"build:app": "yarn --cwd ./excalidraw-app build:app",
|
"build:app": "yarn --cwd ./excalidraw-app build:app",
|
||||||
"build:common": "yarn --cwd ./packages/common build:esm",
|
"build:package": "yarn --cwd ./packages/excalidraw build:esm",
|
||||||
"build:element": "yarn --cwd ./packages/element build:esm",
|
|
||||||
"build:excalidraw": "yarn --cwd ./packages/excalidraw build:esm",
|
|
||||||
"build:math": "yarn --cwd ./packages/math build:esm",
|
|
||||||
"build:packages": "yarn build:common && yarn build:math && yarn build:element && yarn build:excalidraw",
|
|
||||||
"build:version": "yarn --cwd ./excalidraw-app build:version",
|
"build:version": "yarn --cwd ./excalidraw-app build:version",
|
||||||
"build": "yarn --cwd ./excalidraw-app build",
|
"build": "yarn --cwd ./excalidraw-app build",
|
||||||
"build:preview": "yarn --cwd ./excalidraw-app build:preview",
|
"build:preview": "yarn --cwd ./excalidraw-app build:preview",
|
||||||
"start": "yarn --cwd ./excalidraw-app start",
|
"start": "yarn --cwd ./excalidraw-app start",
|
||||||
"start:production": "yarn --cwd ./excalidraw-app start:production",
|
"start:production": "yarn --cwd ./excalidraw-app start:production",
|
||||||
"start:example": "yarn build:packages && yarn --cwd ./examples/with-script-in-browser start",
|
"start:example": "yarn build:package && yarn --cwd ./examples/with-script-in-browser start",
|
||||||
"test:all": "yarn test:typecheck && yarn test:code && yarn test:other && yarn test:app --watch=false",
|
"test:all": "yarn test:typecheck && yarn test:code && yarn test:other && yarn test:app --watch=false",
|
||||||
"test:app": "vitest",
|
"test:app": "vitest",
|
||||||
"test:code": "eslint --max-warnings=0 --ext .js,.ts,.tsx .",
|
"test:code": "eslint --max-warnings=0 --ext .js,.ts,.tsx .",
|
||||||
@@ -80,12 +76,11 @@
|
|||||||
"locales-coverage:description": "node scripts/locales-coverage-description.js",
|
"locales-coverage:description": "node scripts/locales-coverage-description.js",
|
||||||
"prepare": "husky install",
|
"prepare": "husky install",
|
||||||
"prettier": "prettier \"**/*.{css,scss,json,md,html,yml}\" --ignore-path=.eslintignore",
|
"prettier": "prettier \"**/*.{css,scss,json,md,html,yml}\" --ignore-path=.eslintignore",
|
||||||
"release": "node scripts/release.js",
|
"autorelease": "node scripts/autorelease.js",
|
||||||
"release:test": "node scripts/release.js --tag=test",
|
"prerelease:excalidraw": "node scripts/prerelease.js",
|
||||||
"release:next": "node scripts/release.js --tag=next",
|
"release:excalidraw": "node scripts/release.js",
|
||||||
"release:latest": "node scripts/release.js --tag=latest",
|
"rm:build": "rm -rf excalidraw-app/{build,dist,dev-dist} && rm -rf packages/*/{dist,build} && rm -rf examples/*/{build,dist}",
|
||||||
"rm:build": "rimraf --glob excalidraw-app/build excalidraw-app/dist excalidraw-app/dev-dist packages/*/dist packages/*/build examples/*/build examples/*/dist",
|
"rm:node_modules": "rm -rf node_modules && rm -rf excalidraw-app/node_modules && rm -rf packages/*/node_modules",
|
||||||
"rm:node_modules": "rimraf --glob node_modules excalidraw-app/node_modules packages/*/node_modules",
|
|
||||||
"clean-install": "yarn rm:node_modules && yarn install"
|
"clean-install": "yarn rm:node_modules && yarn install"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["../eslintrc.base.json"]
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
# @excalidraw/common
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install @excalidraw/common
|
|
||||||
```
|
|
||||||
|
|
||||||
If you prefer Yarn over npm, use this command to install the Excalidraw utils package:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn add @excalidraw/common
|
|
||||||
```
|
|
||||||
|
|
||||||
With PNPM, similarly install the package with this command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pnpm add @excalidraw/common
|
|
||||||
```
|
|
||||||
Vendored
-3
@@ -1,3 +0,0 @@
|
|||||||
/// <reference types="vite/client" />
|
|
||||||
import "@excalidraw/excalidraw/global";
|
|
||||||
import "@excalidraw/excalidraw/css";
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@excalidraw/common",
|
|
||||||
"version": "0.18.0",
|
|
||||||
"type": "module",
|
|
||||||
"types": "./dist/types/common/src/index.d.ts",
|
|
||||||
"main": "./dist/prod/index.js",
|
|
||||||
"module": "./dist/prod/index.js",
|
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"types": "./dist/types/common/src/index.d.ts",
|
|
||||||
"development": "./dist/dev/index.js",
|
|
||||||
"production": "./dist/prod/index.js",
|
|
||||||
"default": "./dist/prod/index.js"
|
|
||||||
},
|
|
||||||
"./*": {
|
|
||||||
"types": "./dist/types/common/src/*.d.ts",
|
|
||||||
"development": "./dist/dev/index.js",
|
|
||||||
"production": "./dist/prod/index.js",
|
|
||||||
"default": "./dist/prod/index.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"dist/*"
|
|
||||||
],
|
|
||||||
"description": "Excalidraw common functions, constants, etc.",
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"keywords": [
|
|
||||||
"excalidraw",
|
|
||||||
"excalidraw-utils"
|
|
||||||
],
|
|
||||||
"browserslist": {
|
|
||||||
"production": [
|
|
||||||
">0.2%",
|
|
||||||
"not dead",
|
|
||||||
"not ie <= 11",
|
|
||||||
"not op_mini all",
|
|
||||||
"not safari < 12",
|
|
||||||
"not kaios <= 2.5",
|
|
||||||
"not edge < 79",
|
|
||||||
"not chrome < 70",
|
|
||||||
"not and_uc < 13",
|
|
||||||
"not samsung < 10"
|
|
||||||
],
|
|
||||||
"development": [
|
|
||||||
"last 1 chrome version",
|
|
||||||
"last 1 firefox version",
|
|
||||||
"last 1 safari version"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"bugs": "https://github.com/excalidraw/excalidraw/issues",
|
|
||||||
"repository": "https://github.com/excalidraw/excalidraw",
|
|
||||||
"scripts": {
|
|
||||||
"gen:types": "rimraf types && tsc",
|
|
||||||
"build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"tinycolor2": "1.6.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/tinycolor2": "1.4.6"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,185 +0,0 @@
|
|||||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
||||||
|
|
||||||
exports[`COLOR_PALETTE > color palette doesn't regress 1`] = `
|
|
||||||
{
|
|
||||||
"black": "#1e1e1e",
|
|
||||||
"blue": [
|
|
||||||
"#e7f5ff",
|
|
||||||
"#a5d8ff",
|
|
||||||
"#4dabf7",
|
|
||||||
"#228be6",
|
|
||||||
"#1971c2",
|
|
||||||
],
|
|
||||||
"bronze": [
|
|
||||||
"#f8f1ee",
|
|
||||||
"#eaddd7",
|
|
||||||
"#d2bab0",
|
|
||||||
"#a18072",
|
|
||||||
"#846358",
|
|
||||||
],
|
|
||||||
"cyan": [
|
|
||||||
"#e3fafc",
|
|
||||||
"#99e9f2",
|
|
||||||
"#3bc9db",
|
|
||||||
"#15aabf",
|
|
||||||
"#0c8599",
|
|
||||||
],
|
|
||||||
"grape": [
|
|
||||||
"#f8f0fc",
|
|
||||||
"#eebefa",
|
|
||||||
"#da77f2",
|
|
||||||
"#be4bdb",
|
|
||||||
"#9c36b5",
|
|
||||||
],
|
|
||||||
"gray": [
|
|
||||||
"#f8f9fa",
|
|
||||||
"#e9ecef",
|
|
||||||
"#ced4da",
|
|
||||||
"#868e96",
|
|
||||||
"#343a40",
|
|
||||||
],
|
|
||||||
"green": [
|
|
||||||
"#ebfbee",
|
|
||||||
"#b2f2bb",
|
|
||||||
"#69db7c",
|
|
||||||
"#40c057",
|
|
||||||
"#2f9e44",
|
|
||||||
],
|
|
||||||
"orange": [
|
|
||||||
"#fff4e6",
|
|
||||||
"#ffd8a8",
|
|
||||||
"#ffa94d",
|
|
||||||
"#fd7e14",
|
|
||||||
"#e8590c",
|
|
||||||
],
|
|
||||||
"pink": [
|
|
||||||
"#fff0f6",
|
|
||||||
"#fcc2d7",
|
|
||||||
"#f783ac",
|
|
||||||
"#e64980",
|
|
||||||
"#c2255c",
|
|
||||||
],
|
|
||||||
"red": [
|
|
||||||
"#fff5f5",
|
|
||||||
"#ffc9c9",
|
|
||||||
"#ff8787",
|
|
||||||
"#fa5252",
|
|
||||||
"#e03131",
|
|
||||||
],
|
|
||||||
"teal": [
|
|
||||||
"#e6fcf5",
|
|
||||||
"#96f2d7",
|
|
||||||
"#38d9a9",
|
|
||||||
"#12b886",
|
|
||||||
"#099268",
|
|
||||||
],
|
|
||||||
"transparent": "transparent",
|
|
||||||
"violet": [
|
|
||||||
"#f3f0ff",
|
|
||||||
"#d0bfff",
|
|
||||||
"#9775fa",
|
|
||||||
"#7950f2",
|
|
||||||
"#6741d9",
|
|
||||||
],
|
|
||||||
"white": "#ffffff",
|
|
||||||
"yellow": [
|
|
||||||
"#fff9db",
|
|
||||||
"#ffec99",
|
|
||||||
"#ffd43b",
|
|
||||||
"#fab005",
|
|
||||||
"#f08c00",
|
|
||||||
],
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`applyDarkModeFilter > COLOR_PALETTE regression tests > matches snapshot for all palette colors 1`] = `
|
|
||||||
{
|
|
||||||
"black": "#d3d3d3",
|
|
||||||
"blue": [
|
|
||||||
"#121e26",
|
|
||||||
"#154162",
|
|
||||||
"#2273b4",
|
|
||||||
"#3791e0",
|
|
||||||
"#56a2e8",
|
|
||||||
],
|
|
||||||
"bronze": [
|
|
||||||
"#221c1a",
|
|
||||||
"#362b26",
|
|
||||||
"#5a463d",
|
|
||||||
"#917569",
|
|
||||||
"#a98d84",
|
|
||||||
],
|
|
||||||
"cyan": [
|
|
||||||
"#0a1e20",
|
|
||||||
"#004149",
|
|
||||||
"#007281",
|
|
||||||
"#0f8fa1",
|
|
||||||
"#3da5b6",
|
|
||||||
],
|
|
||||||
"grape": [
|
|
||||||
"#211a25",
|
|
||||||
"#5b3165",
|
|
||||||
"#a954be",
|
|
||||||
"#d471ed",
|
|
||||||
"#e28af8",
|
|
||||||
],
|
|
||||||
"gray": [
|
|
||||||
"#161718",
|
|
||||||
"#202325",
|
|
||||||
"#33383d",
|
|
||||||
"#6e757c",
|
|
||||||
"#b7bcc1",
|
|
||||||
],
|
|
||||||
"green": [
|
|
||||||
"#0f1d12",
|
|
||||||
"#043b0c",
|
|
||||||
"#056715",
|
|
||||||
"#16842a",
|
|
||||||
"#39994b",
|
|
||||||
],
|
|
||||||
"orange": [
|
|
||||||
"#22190d",
|
|
||||||
"#4c2b01",
|
|
||||||
"#924800",
|
|
||||||
"#cd6005",
|
|
||||||
"#f17634",
|
|
||||||
],
|
|
||||||
"pink": [
|
|
||||||
"#26191e",
|
|
||||||
"#602e40",
|
|
||||||
"#b04d70",
|
|
||||||
"#f56e9d",
|
|
||||||
"#ff8dbc",
|
|
||||||
],
|
|
||||||
"red": [
|
|
||||||
"#1f1717",
|
|
||||||
"#5a2c2c",
|
|
||||||
"#b44d4d",
|
|
||||||
"#fa6969",
|
|
||||||
"#ff8383",
|
|
||||||
],
|
|
||||||
"teal": [
|
|
||||||
"#0a1d17",
|
|
||||||
"#00422b",
|
|
||||||
"#00744b",
|
|
||||||
"#039267",
|
|
||||||
"#32a783",
|
|
||||||
],
|
|
||||||
"transparent": "#ededed00",
|
|
||||||
"violet": [
|
|
||||||
"#1f1c29",
|
|
||||||
"#4a3b72",
|
|
||||||
"#8a6cdf",
|
|
||||||
"#a885ff",
|
|
||||||
"#b595ff",
|
|
||||||
],
|
|
||||||
"white": "#121212",
|
|
||||||
"yellow": [
|
|
||||||
"#1e1900",
|
|
||||||
"#362600",
|
|
||||||
"#5f3a00",
|
|
||||||
"#905000",
|
|
||||||
"#b86200",
|
|
||||||
],
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
import { AppEventBus } from "./appEventBus";
|
|
||||||
|
|
||||||
type TestEvents = {
|
|
||||||
initialize: [api: number];
|
|
||||||
pointerUp: [pointerId: string];
|
|
||||||
viewState: [zoom: number];
|
|
||||||
};
|
|
||||||
|
|
||||||
const behavior = {
|
|
||||||
initialize: { cardinality: "once", replay: "last" },
|
|
||||||
pointerUp: { cardinality: "many", replay: "none" },
|
|
||||||
viewState: { cardinality: "many", replay: "last" },
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
const flushMicrotasks = async () => Promise.resolve();
|
|
||||||
|
|
||||||
describe("AppEventBus", () => {
|
|
||||||
it("replays once events to late callback and Promise subscribers", async () => {
|
|
||||||
const bus = new AppEventBus<TestEvents, typeof behavior>(behavior);
|
|
||||||
bus.emit("initialize", 42);
|
|
||||||
|
|
||||||
const calls: number[] = [];
|
|
||||||
bus.on("initialize", (value) => {
|
|
||||||
calls.push(value);
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(calls).toEqual([]);
|
|
||||||
await flushMicrotasks();
|
|
||||||
expect(calls).toEqual([42]);
|
|
||||||
|
|
||||||
await expect(bus.on("initialize")).resolves.toBe(42);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not replay stream events to late subscribers", async () => {
|
|
||||||
const bus = new AppEventBus<TestEvents, typeof behavior>(behavior);
|
|
||||||
bus.emit("pointerUp", "first");
|
|
||||||
|
|
||||||
const calls: string[] = [];
|
|
||||||
bus.on("pointerUp", (pointerId) => {
|
|
||||||
calls.push(pointerId);
|
|
||||||
});
|
|
||||||
|
|
||||||
await flushMicrotasks();
|
|
||||||
expect(calls).toEqual([]);
|
|
||||||
|
|
||||||
bus.emit("pointerUp", "second");
|
|
||||||
expect(calls).toEqual(["second"]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("replays replay-last stream events and stays subscribed", async () => {
|
|
||||||
const bus = new AppEventBus<TestEvents, typeof behavior>(behavior);
|
|
||||||
bus.emit("viewState", 1);
|
|
||||||
|
|
||||||
const calls: number[] = [];
|
|
||||||
bus.on("viewState", (zoom) => {
|
|
||||||
calls.push(zoom);
|
|
||||||
});
|
|
||||||
|
|
||||||
await flushMicrotasks();
|
|
||||||
expect(calls).toEqual([1]);
|
|
||||||
|
|
||||||
bus.emit("viewState", 2);
|
|
||||||
expect(calls).toEqual([1, 2]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("throws when emitting a once event twice", () => {
|
|
||||||
const bus = new AppEventBus<TestEvents, typeof behavior>(behavior);
|
|
||||||
bus.emit("initialize", 1);
|
|
||||||
|
|
||||||
expect(() => {
|
|
||||||
bus.emit("initialize", 2);
|
|
||||||
}).toThrow('Event "initialize" can only be emitted once');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
import type { UnsubscribeCallback } from "@excalidraw/excalidraw/types";
|
|
||||||
|
|
||||||
import { Emitter } from "./emitter";
|
|
||||||
import { isProdEnv } from "./utils";
|
|
||||||
|
|
||||||
export type AppEventPayloadMap = Record<string, unknown[]>;
|
|
||||||
|
|
||||||
export type AppEventBehavior = {
|
|
||||||
cardinality: "once" | "many";
|
|
||||||
replay: "none" | "last";
|
|
||||||
};
|
|
||||||
|
|
||||||
export type AppEventBehaviorMap<Events extends AppEventPayloadMap> = {
|
|
||||||
[K in keyof Events]: AppEventBehavior;
|
|
||||||
};
|
|
||||||
|
|
||||||
type AwaitableAppEventKeys<
|
|
||||||
Events extends AppEventPayloadMap,
|
|
||||||
Behavior extends AppEventBehaviorMap<Events>,
|
|
||||||
> = {
|
|
||||||
[K in keyof Events]: Behavior[K]["cardinality"] extends "once"
|
|
||||||
? Behavior[K]["replay"] extends "last"
|
|
||||||
? K
|
|
||||||
: never
|
|
||||||
: never;
|
|
||||||
}[keyof Events];
|
|
||||||
|
|
||||||
type AppEventPromiseValue<Args extends any[]> = Args extends [infer Only]
|
|
||||||
? Only
|
|
||||||
: Args;
|
|
||||||
|
|
||||||
export class AppEventBus<
|
|
||||||
Events extends AppEventPayloadMap,
|
|
||||||
Behavior extends AppEventBehaviorMap<Events>,
|
|
||||||
> {
|
|
||||||
private readonly emitters = new Map<keyof Events, Emitter<any>>();
|
|
||||||
private readonly lastPayload = new Map<keyof Events, any[]>();
|
|
||||||
private readonly emittedOnce = new Set<keyof Events>();
|
|
||||||
|
|
||||||
constructor(private readonly behavior: Behavior) {}
|
|
||||||
|
|
||||||
private getEmitter<K extends keyof Events>(name: K): Emitter<Events[K]> {
|
|
||||||
let emitter = this.emitters.get(name);
|
|
||||||
if (!emitter) {
|
|
||||||
emitter = new Emitter<any>();
|
|
||||||
this.emitters.set(name, emitter);
|
|
||||||
}
|
|
||||||
return emitter as Emitter<Events[K]>;
|
|
||||||
}
|
|
||||||
|
|
||||||
private toPromiseValue<Args extends any[]>(
|
|
||||||
args: Args,
|
|
||||||
): AppEventPromiseValue<Args> {
|
|
||||||
return (args.length === 1 ? args[0] : args) as AppEventPromiseValue<Args>;
|
|
||||||
}
|
|
||||||
|
|
||||||
public on<K extends keyof Events>(
|
|
||||||
name: K,
|
|
||||||
callback: (...args: Events[K]) => void,
|
|
||||||
): UnsubscribeCallback;
|
|
||||||
public on<K extends AwaitableAppEventKeys<Events, Behavior>>(
|
|
||||||
name: K,
|
|
||||||
): Promise<AppEventPromiseValue<Events[K]>>;
|
|
||||||
public on<K extends keyof Events>(
|
|
||||||
name: K,
|
|
||||||
callback?: (...args: Events[K]) => void,
|
|
||||||
): UnsubscribeCallback | Promise<AppEventPromiseValue<Events[K]>> {
|
|
||||||
const eventBehavior = this.behavior[name];
|
|
||||||
const cachedPayload = this.lastPayload.get(name) as Events[K] | undefined;
|
|
||||||
|
|
||||||
if (callback) {
|
|
||||||
if (eventBehavior.replay === "last" && cachedPayload) {
|
|
||||||
queueMicrotask(() => callback(...cachedPayload));
|
|
||||||
|
|
||||||
if (eventBehavior.cardinality === "once") {
|
|
||||||
return () => {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.getEmitter(name).on(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
eventBehavior.cardinality !== "once" ||
|
|
||||||
eventBehavior.replay !== "last"
|
|
||||||
) {
|
|
||||||
throw new Error(`Event "${String(name)}" requires a callback`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cachedPayload) {
|
|
||||||
return Promise.resolve(this.toPromiseValue(cachedPayload));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise<AppEventPromiseValue<Events[K]>>((resolve) => {
|
|
||||||
this.getEmitter(name).once((...args: Events[K]) => {
|
|
||||||
resolve(this.toPromiseValue(args));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public emit<K extends keyof Events>(name: K, ...args: Events[K]) {
|
|
||||||
const eventBehavior = this.behavior[name];
|
|
||||||
|
|
||||||
if (!isProdEnv()) {
|
|
||||||
if (eventBehavior.cardinality === "once") {
|
|
||||||
if (this.emittedOnce.has(name)) {
|
|
||||||
throw new Error(`Event "${String(name)}" can only be emitted once`);
|
|
||||||
}
|
|
||||||
this.emittedOnce.add(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eventBehavior.replay === "last") {
|
|
||||||
this.lastPayload.set(name, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.getEmitter(name).trigger(...args);
|
|
||||||
} finally {
|
|
||||||
if (eventBehavior.cardinality === "once") {
|
|
||||||
this.getEmitter(name).clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public clear() {
|
|
||||||
this.lastPayload.clear();
|
|
||||||
this.emittedOnce.clear();
|
|
||||||
|
|
||||||
for (const emitter of this.emitters.values()) {
|
|
||||||
emitter.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.emitters.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user