Compare commits
222 Commits
v0.12.0
...
zsviczian-
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5fcf6a4845 | ||
![]() |
af3b93c410 | ||
![]() |
2595e0de82 | ||
![]() |
8ec5f7b982 | ||
![]() |
9086674b27 | ||
![]() |
6273d56524 | ||
![]() |
7e135c4e22 | ||
![]() |
b704705ed8 | ||
![]() |
d2e371cdf0 | ||
![]() |
6ab3f0eb74 | ||
![]() |
539505affd | ||
![]() |
95d669390f | ||
![]() |
73a45e1988 | ||
![]() |
88c2812949 | ||
![]() |
bdb14723b3 | ||
![]() |
cc9e764585 | ||
![]() |
8466eb0eef | ||
![]() |
0ebe6292a3 | ||
![]() |
5854ac3eed | ||
![]() |
65d84a5d5a | ||
![]() |
808366d112 | ||
![]() |
9311c99d3c | ||
![]() |
d131b31084 | ||
![]() |
0111ca2050 | ||
![]() |
a1dcd6d984 | ||
![]() |
fffd4957db | ||
![]() |
760fd7b3a6 | ||
![]() |
1933116261 | ||
![]() |
8b33ca3a1a | ||
![]() |
a86224c797 | ||
![]() |
66bbfda460 | ||
![]() |
88b2f4707d | ||
![]() |
25c6056b03 | ||
![]() |
baf9651d34 | ||
![]() |
d2181847be | ||
![]() |
1f117995d9 | ||
![]() |
52c96a6870 | ||
![]() |
81fd2350a9 | ||
![]() |
8ed0fc2c87 | ||
![]() |
96a5d6548b | ||
![]() |
4709b953e7 | ||
![]() |
bbe0c35f66 | ||
![]() |
d273acb7e4 | ||
![]() |
3c0b29d85f | ||
![]() |
bfbaeae67f | ||
![]() |
74b9885955 | ||
![]() |
2cbe869a13 | ||
![]() |
a48607eb25 | ||
![]() |
7831b6e74b | ||
![]() |
640affe7c0 | ||
![]() |
335aff8838 | ||
![]() |
dc97dc30bf | ||
![]() |
a0ecfed4cd | ||
![]() |
e201e79cd0 | ||
![]() |
e1c5c706c6 | ||
![]() |
bdc56090d7 | ||
![]() |
58accc9310 | ||
![]() |
b91158198e | ||
![]() |
938ce241ff | ||
![]() |
0228646507 | ||
![]() |
25ea97d0f9 | ||
![]() |
8d5d68e589 | ||
![]() |
6c15d9948b | ||
![]() |
e8fba43cf6 | ||
![]() |
2e5c798c71 | ||
![]() |
8c298336fc | ||
![]() |
7f91cdc0c9 | ||
![]() |
6334bd832f | ||
![]() |
4d26993c8f | ||
![]() |
1e69609ce4 | ||
![]() |
f5379d1563 | ||
![]() |
c8f6e3faa8 | ||
![]() |
36bf17cf59 | ||
![]() |
75458c3192 | ||
![]() |
4cd25253bf | ||
![]() |
78e254fb30 | ||
![]() |
79bd3b8cda | ||
![]() |
55110bf1b8 | ||
![]() |
941b2d7042 | ||
![]() |
e9067de173 | ||
![]() |
fdc462ec01 | ||
![]() |
d1441afec9 | ||
![]() |
3298aaf0c7 | ||
![]() |
e9a224a0de | ||
![]() |
76cf560914 | ||
![]() |
6c1246ef77 | ||
![]() |
b477c2ad6b | ||
![]() |
4cb6f09559 | ||
![]() |
8636ef1017 | ||
![]() |
3a776f8795 | ||
![]() |
9929a2be6f | ||
![]() |
9cccac1458 | ||
![]() |
7eaf47c9d4 | ||
![]() |
ec4b3d913e | ||
![]() |
5390617c01 | ||
![]() |
0d1058a596 | ||
![]() |
c5869979c8 | ||
![]() |
6a6b9c90a7 | ||
![]() |
5c17751662 | ||
![]() |
898789b979 | ||
![]() |
7922ce129e | ||
![]() |
59ec1c6cee | ||
![]() |
933c6a2237 | ||
![]() |
cd61f31116 | ||
![]() |
b3052f0178 | ||
![]() |
a271e42af1 | ||
![]() |
836120c14b | ||
![]() |
da4fa91ffc | ||
![]() |
553b493f37 | ||
![]() |
59a1d192d2 | ||
![]() |
8b7302e89e | ||
![]() |
f9b7cfd8aa | ||
![]() |
2b4462c941 | ||
![]() |
43b13d8e3a | ||
![]() |
720f468f39 | ||
![]() |
33300d19f6 | ||
![]() |
5aed159991 | ||
![]() |
de1d221d1c | ||
![]() |
9a68dbffe2 | ||
![]() |
32d82219b1 | ||
![]() |
ba2c86fe1b | ||
![]() |
f1ae37c84b | ||
![]() |
ec350ba8b2 | ||
![]() |
46a61ad4df | ||
![]() |
f4b1a30bef | ||
![]() |
32aa79164b | ||
![]() |
b5fd904808 | ||
![]() |
8f8dd1105f | ||
![]() |
b914ad41fc | ||
![]() |
551c38f60b | ||
![]() |
38e8ae46c9 | ||
![]() |
ad0c4c4c78 | ||
![]() |
27cf5ed17e | ||
![]() |
fd946adbae | ||
![]() |
c37977af4b | ||
![]() |
a0d413ab4e | ||
![]() |
b67a2b4f65 | ||
![]() |
5a8dbe8030 | ||
![]() |
731093f631 | ||
![]() |
fe56975f19 | ||
![]() |
2d800feeeb | ||
![]() |
93cccd596a | ||
![]() |
45b592227d | ||
![]() |
b818df1098 | ||
![]() |
4359e2935d | ||
![]() |
3d9d398378 | ||
![]() |
0a5da0269f | ||
![]() |
08ce7c7fc3 | ||
![]() |
fe7fbff7f6 | ||
![]() |
501397cb61 | ||
![]() |
865d29388c | ||
![]() |
54c7ec416a | ||
![]() |
aca284057d | ||
![]() |
2820cd112e | ||
![]() |
426b5d9537 | ||
![]() |
e7d34677c6 | ||
![]() |
3d5356cb8e | ||
![]() |
46f5ce5ce0 | ||
![]() |
b00bd3d6c0 | ||
![]() |
91fc22182c | ||
![]() |
966ca2ffa6 | ||
![]() |
2b049b4a65 | ||
![]() |
339212e563 | ||
![]() |
f8b4bb66b4 | ||
![]() |
f4312bba5e | ||
![]() |
ac66665b64 | ||
![]() |
2b71a1f0bd | ||
![]() |
58845e450a | ||
![]() |
15d79f8fee | ||
![]() |
958ebeae61 | ||
![]() |
31f51ca53b | ||
![]() |
5abbf73050 | ||
![]() |
7cf766630d | ||
![]() |
59fccafeac | ||
![]() |
19a6996e6b | ||
![]() |
86c4f90910 | ||
![]() |
4d88112021 | ||
![]() |
de5c63e299 | ||
![]() |
da0853a121 | ||
![]() |
57cc4b6a29 | ||
![]() |
e2ddd7b27a | ||
![]() |
693de8501e | ||
![]() |
c6df6d444e | ||
![]() |
ad5692c5f8 | ||
![]() |
60ab3337af | ||
![]() |
dd847793d2 | ||
![]() |
6d6e9f0dd3 | ||
![]() |
0fe0d7ca6b | ||
![]() |
abcf1f1bae | ||
![]() |
7d0b03f754 | ||
![]() |
bd8931d3d1 | ||
![]() |
0d86c04939 | ||
![]() |
8436ebbf68 | ||
![]() |
824f94b3df | ||
![]() |
f9a8e686b2 | ||
![]() |
e442a44ba8 | ||
![]() |
f1fd29571a | ||
![]() |
6a482a7ba2 | ||
![]() |
bfea434a55 | ||
![]() |
acb22c5a64 | ||
![]() |
7cd1b621d1 | ||
![]() |
9c37b25bab | ||
![]() |
a8bb9a78ef | ||
![]() |
e4aff04061 | ||
![]() |
c5cadc7de3 | ||
![]() |
7dc0c0d96a | ||
![]() |
2c9c8c8e05 | ||
![]() |
b5d7ae57e5 | ||
![]() |
0f66ee3a41 | ||
![]() |
771372c66b | ||
![]() |
a7937681e9 | ||
![]() |
792f238d16 | ||
![]() |
ba16416c75 | ||
![]() |
6e0ac52a64 | ||
![]() |
5bc40402a6 | ||
![]() |
df14c69977 | ||
![]() |
1ea67ba93d | ||
![]() |
a7153d9d1d | ||
![]() |
e885057a71 | ||
![]() |
7efa081976 | ||
![]() |
5deb93a083 | ||
![]() |
e3908e6fe3 |
43
.codesandbox/tasks.json
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
// These tasks will run in order when initializing your CodeSandbox project.
|
||||||
|
"setupTasks": [
|
||||||
|
{
|
||||||
|
"name": "Install Dependencies",
|
||||||
|
"command": "yarn install"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
// These tasks can be run from CodeSandbox. Running one will open a log in the app.
|
||||||
|
"tasks": {
|
||||||
|
"build": {
|
||||||
|
"name": "Build",
|
||||||
|
"command": "yarn build",
|
||||||
|
"runAtStart": false
|
||||||
|
},
|
||||||
|
"fix": {
|
||||||
|
"name": "Fix",
|
||||||
|
"command": "yarn fix",
|
||||||
|
"runAtStart": false
|
||||||
|
},
|
||||||
|
"prettier": {
|
||||||
|
"name": "Prettify",
|
||||||
|
"command": "yarn prettier",
|
||||||
|
"runAtStart": false
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"name": "Start Excalidraw",
|
||||||
|
"command": "yarn start",
|
||||||
|
"runAtStart": true
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"name": "Run Tests",
|
||||||
|
"command": "yarn test",
|
||||||
|
"runAtStart": false
|
||||||
|
},
|
||||||
|
"install-deps": {
|
||||||
|
"name": "Install Dependencies",
|
||||||
|
"command": "yarn install",
|
||||||
|
"restartOn": { "files": ["yarn.lock"] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,6 @@
|
|||||||
*
|
*
|
||||||
!.env
|
!.env.development
|
||||||
|
!.env.production
|
||||||
!.eslintrc.json
|
!.eslintrc.json
|
||||||
!.npmrc
|
!.npmrc
|
||||||
!.prettierrc
|
!.prettierrc
|
||||||
|
@@ -20,3 +20,5 @@ REACT_APP_DEV_ENABLE_SW=
|
|||||||
# whether to disable live reload / HMR. Usuaully what you want to do when
|
# whether to disable live reload / HMR. Usuaully what you want to do when
|
||||||
# debugging Service Workers.
|
# debugging Service Workers.
|
||||||
REACT_APP_DEV_DISABLE_LIVE_RELOAD=
|
REACT_APP_DEV_DISABLE_LIVE_RELOAD=
|
||||||
|
|
||||||
|
FAST_REFRESH=false
|
||||||
|
2
.github/workflows/autorelease-excalidraw.yml
vendored
@@ -2,7 +2,7 @@ name: Auto release excalidraw next
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- release
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Auto-release-excalidraw-next:
|
Auto-release-excalidraw-next:
|
||||||
|
2
.github/workflows/build-docker.yml
vendored
@@ -3,7 +3,7 @@ name: Build Docker image
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- release
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-docker:
|
build-docker:
|
||||||
|
2
.github/workflows/cancel.yml
vendored
@@ -3,7 +3,7 @@ name: Cancel previous runs
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- release
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
17
.github/workflows/publish-docker.yml
vendored
@@ -3,18 +3,23 @@ name: Publish Docker
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- release
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-docker:
|
publish-docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Checkout repository
|
||||||
- uses: docker/build-push-action@v2
|
uses: actions/checkout@v3
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
repository: excalidraw/excalidraw
|
- name: Build and push
|
||||||
tag_with_ref: true
|
uses: docker/build-push-action@v3
|
||||||
tag_with_sha: true
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: excalidraw/excalidraw:latest
|
||||||
|
2
.github/workflows/sentry-production.yml
vendored
@@ -3,7 +3,7 @@ name: New Sentry production release
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- release
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
sentry:
|
sentry:
|
||||||
|
2
.gitignore
vendored
@@ -19,11 +19,9 @@ logs
|
|||||||
node_modules
|
node_modules
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
package-lock.json
|
package-lock.json
|
||||||
static
|
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
src/packages/excalidraw/types
|
src/packages/excalidraw/types
|
||||||
src/packages/excalidraw/example/public/bundle.js
|
src/packages/excalidraw/example/public/bundle.js
|
||||||
src/packages/excalidraw/example/public/excalidraw-assets-dev
|
src/packages/excalidraw/example/public/excalidraw-assets-dev
|
||||||
src/packages/excalidraw/example/public/excalidraw.development.js
|
src/packages/excalidraw/example/public/excalidraw.development.js
|
||||||
|
|
||||||
|
@@ -88,7 +88,7 @@ Try out [`@excalidraw/excalidraw`](https://www.npmjs.com/package/@excalidraw/exc
|
|||||||
|
|
||||||
### Code Sandbox
|
### Code Sandbox
|
||||||
|
|
||||||
- Go to https://codesandbox.io/s/github/excalidraw/excalidraw
|
- Go to https://codesandbox.io/p/github/excalidraw/excalidraw
|
||||||
- You may need to sign in with GitHub and reload the page
|
- You may need to sign in with GitHub and reload the page
|
||||||
- You can start coding instantly, and even send PRs from there!
|
- You can start coding instantly, and even send PRs from there!
|
||||||
|
|
||||||
|
20
dev-docs/.gitignore
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Dependencies
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
# Production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.docusaurus
|
||||||
|
.cache-loader
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
.DS_Store
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
41
dev-docs/README.md
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Website
|
||||||
|
|
||||||
|
This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
|
||||||
|
```
|
||||||
|
$ yarn
|
||||||
|
```
|
||||||
|
|
||||||
|
### Local Development
|
||||||
|
|
||||||
|
```
|
||||||
|
$ yarn start
|
||||||
|
```
|
||||||
|
|
||||||
|
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
|
||||||
|
|
||||||
|
### Build
|
||||||
|
|
||||||
|
```
|
||||||
|
$ yarn build
|
||||||
|
```
|
||||||
|
|
||||||
|
This command generates static content into the `build` directory and can be served using any static contents hosting service.
|
||||||
|
|
||||||
|
### Deployment
|
||||||
|
|
||||||
|
Using SSH:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ USE_SSH=true yarn deploy
|
||||||
|
```
|
||||||
|
|
||||||
|
Not using SSH:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ GIT_USER=<Your GitHub username> yarn deploy
|
||||||
|
```
|
||||||
|
|
||||||
|
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
|
3
dev-docs/babel.config.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
presets: [require.resolve("@docusaurus/core/lib/babel/preset")],
|
||||||
|
};
|
6
dev-docs/docs/codebase/overview.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
sidebar_position: 1
|
||||||
|
title: Overview
|
||||||
|
---
|
||||||
|
|
||||||
|
In development. For now, refer to [excalidraw Readme](https://github.com/excalidraw/excalidraw/blob/master/README.md).
|
8
dev-docs/docs/get-started.md
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
sidebar_position: 1
|
||||||
|
title: Introduction
|
||||||
|
---
|
||||||
|
|
||||||
|
Want to integrate Excalidraw into your app? Head over to the [package docs](/docs/package/overview).
|
||||||
|
|
||||||
|
If you're looking into the Excalidraw codebase itself, start [here](/docs/codebase/overview).
|
6
dev-docs/docs/package/overview.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
sidebar_position: 1
|
||||||
|
title: Overview
|
||||||
|
---
|
||||||
|
|
||||||
|
In development. For now, refer to [excalidraw package readme](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md).
|
121
dev-docs/docusaurus.config.js
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
// @ts-check
|
||||||
|
// Note: type annotations allow type checking and IDEs autocompletion
|
||||||
|
|
||||||
|
const lightCodeTheme = require("prism-react-renderer/themes/github");
|
||||||
|
const darkCodeTheme = require("prism-react-renderer/themes/dracula");
|
||||||
|
|
||||||
|
/** @type {import('@docusaurus/types').Config} */
|
||||||
|
const config = {
|
||||||
|
title: "Excalidraw developer docs",
|
||||||
|
tagline:
|
||||||
|
"For Excalidraw contributors or those integrating the Excalidraw editor",
|
||||||
|
url: "https://docs.excalidraw.com.com",
|
||||||
|
baseUrl: "/",
|
||||||
|
onBrokenLinks: "throw",
|
||||||
|
onBrokenMarkdownLinks: "warn",
|
||||||
|
favicon: "img/favicon.ico",
|
||||||
|
organizationName: "Excalidraw", // Usually your GitHub org/user name.
|
||||||
|
projectName: "excalidraw", // Usually your repo name.
|
||||||
|
|
||||||
|
// Even if you don't use internalization, you can use this field to set useful
|
||||||
|
// metadata like html lang. For example, if your site is Chinese, you may want
|
||||||
|
// to replace "en" with "zh-Hans".
|
||||||
|
i18n: {
|
||||||
|
defaultLocale: "en",
|
||||||
|
locales: ["en"],
|
||||||
|
},
|
||||||
|
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
"classic",
|
||||||
|
/** @type {import('@docusaurus/preset-classic').Options} */
|
||||||
|
({
|
||||||
|
docs: {
|
||||||
|
sidebarPath: require.resolve("./sidebars.js"),
|
||||||
|
// Please change this to your repo.
|
||||||
|
editUrl: "https://github.com/excalidraw/docs/tree/master/",
|
||||||
|
},
|
||||||
|
theme: {
|
||||||
|
customCss: require.resolve("./src/css/custom.css"),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
themeConfig:
|
||||||
|
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
|
||||||
|
({
|
||||||
|
navbar: {
|
||||||
|
title: "Excalidraw Docs",
|
||||||
|
logo: {
|
||||||
|
alt: "Excalidraw Logo",
|
||||||
|
src: "img/logo.svg",
|
||||||
|
},
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
type: "doc",
|
||||||
|
docId: "get-started",
|
||||||
|
position: "left",
|
||||||
|
label: "Get started",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
to: "https://blog.excalidraw.com",
|
||||||
|
label: "Blog",
|
||||||
|
position: "left",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
to: "https://github.com/excalidraw/excalidraw",
|
||||||
|
label: "GitHub",
|
||||||
|
position: "right",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
footer: {
|
||||||
|
style: "dark",
|
||||||
|
links: [
|
||||||
|
{
|
||||||
|
title: "Docs",
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
label: "Get Started",
|
||||||
|
to: "/docs/get-started",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Community",
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
label: "Discord",
|
||||||
|
href: "https://discord.gg/UexuTaE",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Twitter",
|
||||||
|
href: "https://twitter.com/excalidraw",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "More",
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
label: "Blog",
|
||||||
|
to: "https://blog.excalidraw.com",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "GitHub",
|
||||||
|
to: "https://github.com/excalidraw/excalidraw",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
copyright: `Made with ❤️ Built with Docusaurus`,
|
||||||
|
},
|
||||||
|
prism: {
|
||||||
|
theme: lightCodeTheme,
|
||||||
|
darkTheme: darkCodeTheme,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = config;
|
46
dev-docs/package.json
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"name": "docs",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"docusaurus": "docusaurus",
|
||||||
|
"start": "docusaurus start --port 3003",
|
||||||
|
"build": "docusaurus build",
|
||||||
|
"swizzle": "docusaurus swizzle",
|
||||||
|
"deploy": "docusaurus deploy",
|
||||||
|
"clear": "docusaurus clear",
|
||||||
|
"serve": "docusaurus serve",
|
||||||
|
"write-translations": "docusaurus write-translations",
|
||||||
|
"write-heading-ids": "docusaurus write-heading-ids",
|
||||||
|
"typecheck": "tsc"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@docusaurus/core": "2.0.0-rc.1",
|
||||||
|
"@docusaurus/preset-classic": "2.0.0-rc.1",
|
||||||
|
"@mdx-js/react": "^1.6.22",
|
||||||
|
"clsx": "^1.2.1",
|
||||||
|
"prism-react-renderer": "^1.3.5",
|
||||||
|
"react": "^17.0.2",
|
||||||
|
"react-dom": "^17.0.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@docusaurus/module-type-aliases": "2.0.0-rc.1",
|
||||||
|
"@tsconfig/docusaurus": "^1.0.5",
|
||||||
|
"typescript": "^4.7.4"
|
||||||
|
},
|
||||||
|
"browserslist": {
|
||||||
|
"production": [
|
||||||
|
">0.5%",
|
||||||
|
"not dead",
|
||||||
|
"not op_mini all"
|
||||||
|
],
|
||||||
|
"development": [
|
||||||
|
"last 1 chrome version",
|
||||||
|
"last 1 firefox version",
|
||||||
|
"last 1 safari version"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16.14"
|
||||||
|
}
|
||||||
|
}
|
31
dev-docs/sidebars.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* Creating a sidebar enables you to:
|
||||||
|
- create an ordered group of docs
|
||||||
|
- render a sidebar for each doc of that group
|
||||||
|
- provide next/previous navigation
|
||||||
|
|
||||||
|
The sidebars can be generated from the filesystem, or explicitly defined here.
|
||||||
|
|
||||||
|
Create as many sidebars as you want.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// @ts-check
|
||||||
|
|
||||||
|
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
|
||||||
|
const sidebars = {
|
||||||
|
// By default, Docusaurus generates a sidebar from the docs folder structure
|
||||||
|
tutorialSidebar: [{ type: "autogenerated", dirName: "." }],
|
||||||
|
|
||||||
|
// But you can create a sidebar manually
|
||||||
|
/*
|
||||||
|
tutorialSidebar: [
|
||||||
|
{
|
||||||
|
type: 'category',
|
||||||
|
label: 'Tutorial',
|
||||||
|
items: ['hello'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = sidebars;
|
62
dev-docs/src/components/Homepage/index.js
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import React from "react";
|
||||||
|
import clsx from "clsx";
|
||||||
|
import styles from "./styles.module.css";
|
||||||
|
|
||||||
|
const FeatureList = [
|
||||||
|
{
|
||||||
|
title: "Learn how Excalidraw works",
|
||||||
|
Svg: require("@site/static/img/undraw_innovative.svg").default,
|
||||||
|
description: (
|
||||||
|
<>Want to contribute to Excalidraw but got lost in the codebase?</>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Integrate Excalidraw",
|
||||||
|
Svg: require("@site/static/img/undraw_blank_canvas.svg").default,
|
||||||
|
description: (
|
||||||
|
<>
|
||||||
|
Want to build your own app powered by Excalidraw by don't know where to
|
||||||
|
start?
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Help us improve",
|
||||||
|
Svg: require("@site/static/img/undraw_add_files.svg").default,
|
||||||
|
description: (
|
||||||
|
<>
|
||||||
|
Are the docs missing something? Anything you had trouble understanding
|
||||||
|
or needs an explanation? Come contribute to the docs to make them even
|
||||||
|
better!
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
function Feature({ Svg, title, description }) {
|
||||||
|
return (
|
||||||
|
<div className={clsx("col col--4")}>
|
||||||
|
<div className="text--center">
|
||||||
|
<Svg className={styles.featureSvg} role="img" />
|
||||||
|
</div>
|
||||||
|
<div className="text--center padding-horiz--md">
|
||||||
|
<h3>{title}</h3>
|
||||||
|
<p>{description}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function HomepageFeatures() {
|
||||||
|
return (
|
||||||
|
<section className={styles.features}>
|
||||||
|
<div className="container">
|
||||||
|
<div className="row">
|
||||||
|
{FeatureList.map((props, idx) => (
|
||||||
|
<Feature key={idx} {...props} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
70
dev-docs/src/components/Homepage/index.tsx
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import React from "react";
|
||||||
|
import clsx from "clsx";
|
||||||
|
import styles from "./styles.module.css";
|
||||||
|
|
||||||
|
type FeatureItem = {
|
||||||
|
title: string;
|
||||||
|
Svg: React.ComponentType<React.ComponentProps<"svg">>;
|
||||||
|
description: JSX.Element;
|
||||||
|
};
|
||||||
|
|
||||||
|
const FeatureList: FeatureItem[] = [
|
||||||
|
{
|
||||||
|
title: "Easy to Use",
|
||||||
|
Svg: require("@site/static/img/undraw_docusaurus_mountain.svg").default,
|
||||||
|
description: (
|
||||||
|
<>
|
||||||
|
Docusaurus was designed from the ground up to be easily installed and
|
||||||
|
used to get your website up and running quickly.
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Focus on What Matters",
|
||||||
|
Svg: require("@site/static/img/undraw_docusaurus_tree.svg").default,
|
||||||
|
description: (
|
||||||
|
<>
|
||||||
|
Docusaurus lets you focus on your docs, and we'll do the chores. Go
|
||||||
|
ahead and move your docs into the <code>docs</code> directory.
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Powered by React",
|
||||||
|
Svg: require("@site/static/img/undraw_docusaurus_react.svg").default,
|
||||||
|
description: (
|
||||||
|
<>
|
||||||
|
Extend or customize your website layout by reusing React. Docusaurus can
|
||||||
|
be extended while reusing the same header and footer.
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
function Feature({ title, Svg, description }: FeatureItem) {
|
||||||
|
return (
|
||||||
|
<div className={clsx("col col--4")}>
|
||||||
|
<div className="text--center">
|
||||||
|
<Svg className={styles.featureSvg} role="img" />
|
||||||
|
</div>
|
||||||
|
<div className="text--center padding-horiz--md">
|
||||||
|
<h3>{title}</h3>
|
||||||
|
<p>{description}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function HomepageFeatures(): JSX.Element {
|
||||||
|
return (
|
||||||
|
<section className={styles.features}>
|
||||||
|
<div className="container">
|
||||||
|
<div className="row">
|
||||||
|
{FeatureList.map((props, idx) => (
|
||||||
|
<Feature key={idx} {...props} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
11
dev-docs/src/components/Homepage/styles.module.css
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
.features {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 2rem 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.featureSvg {
|
||||||
|
height: 200px;
|
||||||
|
width: 200px;
|
||||||
|
}
|
43
dev-docs/src/css/custom.css
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* Any CSS included here will be global. The classic template
|
||||||
|
* bundles Infima by default. Infima is a CSS framework designed to
|
||||||
|
* work well for content-centric websites.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* You can override the default Infima variables here. */
|
||||||
|
:root {
|
||||||
|
--ifm-color-primary: #6965db;
|
||||||
|
--ifm-color-primary-dark: #5b57d1;
|
||||||
|
--ifm-color-primary-darker: #5b57d1;
|
||||||
|
--ifm-color-primary-darkest: #4a47b1;
|
||||||
|
--ifm-color-primary-light: #5b57d1;
|
||||||
|
--ifm-color-primary-lighter: #5b57d1;
|
||||||
|
--ifm-color-primary-lightest: #5b57d1;
|
||||||
|
--ifm-code-font-size: 95%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* For readability concerns, you should choose a lighter palette in dark mode. */
|
||||||
|
[data-theme="dark"] {
|
||||||
|
--ifm-color-primary: #5650f0;
|
||||||
|
--ifm-color-primary-dark: #4b46d8;
|
||||||
|
--ifm-color-primary-darker: #4b46d8;
|
||||||
|
--ifm-color-primary-darkest: #3e39be;
|
||||||
|
--ifm-color-primary-light: #3f3d64;
|
||||||
|
--ifm-color-primary-lighter: #3f3d64;
|
||||||
|
--ifm-color-primary-lightest: #3f3d64;
|
||||||
|
}
|
||||||
|
|
||||||
|
.docusaurus-highlight-code-line {
|
||||||
|
background-color: rgba(0, 0, 0, 0.1);
|
||||||
|
display: block;
|
||||||
|
margin: 0 calc(-1 * var(--ifm-pre-padding));
|
||||||
|
padding: 0 var(--ifm-pre-padding);
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="dark"] .docusaurus-highlight-code-line {
|
||||||
|
background-color: rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="dark"] .navbar__logo {
|
||||||
|
filter: invert(93%) hue-rotate(180deg);
|
||||||
|
}
|
42
dev-docs/src/pages/index.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import React from "react";
|
||||||
|
import clsx from "clsx";
|
||||||
|
import Layout from "@theme/Layout";
|
||||||
|
import Link from "@docusaurus/Link";
|
||||||
|
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
||||||
|
import styles from "./index.module.css";
|
||||||
|
import HomepageFeatures from "@site/src/components/Homepage";
|
||||||
|
|
||||||
|
function HomepageHeader() {
|
||||||
|
const { siteConfig } = useDocusaurusContext();
|
||||||
|
return (
|
||||||
|
<header className={clsx("hero hero--primary", styles.heroBanner)}>
|
||||||
|
<div className="container">
|
||||||
|
<h1 className="hero__title">{siteConfig.title}</h1>
|
||||||
|
<p className="hero__subtitle">{siteConfig.tagline}</p>
|
||||||
|
<div className={styles.buttons}>
|
||||||
|
<Link
|
||||||
|
className="button button--secondary button--lg"
|
||||||
|
to="/docs/get-started"
|
||||||
|
>
|
||||||
|
Get started
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Home() {
|
||||||
|
const { siteConfig } = useDocusaurusContext();
|
||||||
|
return (
|
||||||
|
<Layout
|
||||||
|
title={`Hello from ${siteConfig.title}`}
|
||||||
|
description="Description will go into a meta tag in <head />"
|
||||||
|
>
|
||||||
|
<HomepageHeader />
|
||||||
|
<main>
|
||||||
|
<HomepageFeatures />
|
||||||
|
</main>
|
||||||
|
</Layout>
|
||||||
|
);
|
||||||
|
}
|
27
dev-docs/src/pages/index.module.css
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* CSS files with the .module.css suffix will be treated as CSS modules
|
||||||
|
* and scoped locally.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.heroBanner {
|
||||||
|
padding: 4rem 0;
|
||||||
|
text-align: center;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme="dark"] .heroBanner {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 996px) {
|
||||||
|
.heroBanner {
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.buttons {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
42
dev-docs/src/pages/index.tsx
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import React from "react";
|
||||||
|
import clsx from "clsx";
|
||||||
|
import Layout from "@theme/Layout";
|
||||||
|
import Link from "@docusaurus/Link";
|
||||||
|
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
||||||
|
import styles from "./index.module.css";
|
||||||
|
import HomepageFeatures from "@site/src/components/Homepage";
|
||||||
|
|
||||||
|
function HomepageHeader() {
|
||||||
|
const { siteConfig } = useDocusaurusContext();
|
||||||
|
return (
|
||||||
|
<header className={clsx("hero hero--primary", styles.heroBanner)}>
|
||||||
|
<div className="container">
|
||||||
|
<h1 className="hero__title">{siteConfig.title}</h1>
|
||||||
|
<p className="hero__subtitle">{siteConfig.tagline}</p>
|
||||||
|
<div className={styles.buttons}>
|
||||||
|
<Link
|
||||||
|
className="button button--secondary button--lg"
|
||||||
|
to="/docs/get-started"
|
||||||
|
>
|
||||||
|
Get started
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Home() {
|
||||||
|
const { siteConfig } = useDocusaurusContext();
|
||||||
|
return (
|
||||||
|
<Layout
|
||||||
|
title={`Hello from ${siteConfig.title}`}
|
||||||
|
description="Description will go into a meta tag in <head />"
|
||||||
|
>
|
||||||
|
<HomepageHeader />
|
||||||
|
<main>
|
||||||
|
<HomepageFeatures />
|
||||||
|
</main>
|
||||||
|
</Layout>
|
||||||
|
);
|
||||||
|
}
|
7
dev-docs/src/pages/markdown-page.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
title: Markdown page example
|
||||||
|
---
|
||||||
|
|
||||||
|
# Markdown page example
|
||||||
|
|
||||||
|
You don't need React to write simple standalone pages.
|
0
dev-docs/static/.nojekyll
Normal file
BIN
dev-docs/static/img/docusaurus.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
dev-docs/static/img/favicon.ico
Normal file
After Width: | Height: | Size: 26 KiB |
4
dev-docs/static/img/logo.svg
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<svg viewBox="0 0 80 180" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2">
|
||||||
|
<path d="M22.197 150.382c-4.179-3.359-10.618-9.051-15.702-13.946l-4.01-3.813.734-5.009c.396-2.732 1.13-8.083 1.582-11.839.508-3.757 1.017-7.286 1.186-7.798.226-.683 0-1.025-.621-1.025-1.073 0-1.13.285 1.807-9.107a617.602 617.602 0 0 1 2.203-7.229c.113-.398.565-.569 1.073-.398.508.227.791.683.621 1.081-.169.455.113.911.565 1.082.621.227.565.683-.395 2.333-1.525 2.562-5.422 24.419-5.648 31.477-.17 5.009-.17 5.066 1.92 7.912 2.033 2.789 6.721 7.001 13.951 12.351 2.033 1.537 4.067 3.245 4.631 3.814.848 1.024 1.243.74 8.36-6.887 4.123-4.383 8.698-8.88 10.166-10.018l2.711-2.049-2.089-4.44c-1.13-2.391-5.705-11.612-10.223-20.377-9.433-18.442-7.513-16.678-18.47-16.849l-7.117-.056-2.372-2.733c-2.485-2.903-2.824-3.984-1.638-5.805.452-.627.791-1.651.791-2.277 0-1.025.395-1.196 2.655-1.309 1.412-.057 2.711-.228 2.88-.399.17-.171.396-3.7.565-7.855l.226-7.513-3.784-8.197C2.485 39.844 0 33.583 0 31.533c0-1.081.226-1.992.452-1.992.565 0 .565.057 23.553 48.382 10.675 22.426 20.785 43.544 22.479 47.016 1.695 3.472 3.22 6.659 3.333 7.115.113.512-3.785 4.439-9.998 9.961-5.591 5.008-10.505 9.562-10.957 10.074-1.299 1.594-3.219 1.082-6.665-1.707Zm1.921-65.458c-2.599-5.066-2.712-5.123-9.828-5.464-6.27-.342-6.383-.285-6.383.911 0 .683-.226 1.593-.508 2.049-.339.512-.113 1.423.678 2.675l1.242 1.935h5.649c3.106.057 6.664.285 7.907.512 1.243.228 2.316.342 2.429.285.113-.057-.452-1.366-1.186-2.903Zm-4.745-9.107c-.452-1.195-1.638-3.7-2.598-5.578-1.581-3.188-1.751-3.301-2.146-1.992-.226.797-.396 3.13-.452 5.236-.057 4.155-.17 4.098 4.575 4.383l1.525.057-.904-2.106Z" style="fill-rule:nonzero;stroke:#000;stroke-width:2px" transform="matrix(1.01351 0 0 -1 9.088 166.517)" />
|
||||||
|
<path d="M23.892 136.835c-1.017-.74-1.299-1.48-1.299-3.358 0-2.22.169-2.562 1.694-3.188 1.525-.626 1.92-.569 3.671.626 2.316 1.594 2.373 1.992.678 4.554-1.468 2.22-2.937 2.618-4.744 1.366Zm3.219-2.049c.904-1.594.339-2.789-1.355-2.789-1.525 0-2.203 1.536-1.356 3.073.678 1.253 1.977 1.139 2.711-.284ZM59.306 124.028c0-.285-.339-.569-.735-.569-.339 0-1.299-1.594-2.033-3.529-2.259-5.92-24.852-50.943-24.908-49.52 0 .74-.339 1.252-.904 1.252-.791 0-.904-.456-.565-2.675.339-2.562.113-3.131-7.907-18.841-4.519-8.936-9.376-18.271-10.788-20.775-1.469-2.619-2.598-5.465-2.711-6.66-.17-2.049.056-2.334 4.97-6.603 2.824-2.504 6.439-5.635 8.02-7.058C28.862 2.504 32.194-.114 33.098.057c1.356.228 22.31 22.369 22.367 23.622 0 .569-1.017 9.221-2.259 19.238-2.147 17.076-4.18 37.055-3.954 38.99.169 1.196-.678 7.229-1.299 9.847-.509 2.05-.283 2.903 3.784 12.238 2.372 5.521 5.479 12.295 6.834 15.027 1.299 2.732 2.429 5.123 2.429 5.294 0 .17-.395.284-.847.284-.452 0-.847-.228-.847-.569ZM46.315 81.509c.621-3.984 1.864-13.547 2.767-21.231 1.751-14.116 3.785-29.769 4.349-33.753.339-1.993.113-2.391-3.558-6.489-6.382-7.229-13.16-14.344-15.476-16.165l-2.146-1.708-11.014 10.359C11.07 21.971 10.223 22.939 10.844 24.077c.339.626 3.22 5.92 6.383 11.725 3.163 5.806 7.342 13.547 9.263 17.19 1.977 3.7 3.784 6.887 4.123 7.058.395.228.508-5.521.395-17.759-.226-18.271-.169-18.328 1.638-17.929.226 0 .396 9.221.396 20.434v20.377l5.93 11.953c3.276 6.603 5.987 11.896 6.1 11.84.113-.058.678-3.416 1.243-7.457Z" style="fill-rule:nonzero;stroke:#000;stroke-width:2px" transform="matrix(1.01351 0 0 -1 9.088 166.517)" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 3.4 KiB |
1
dev-docs/static/img/undraw_add_files.svg
Normal file
After Width: | Height: | Size: 5.7 KiB |
1
dev-docs/static/img/undraw_blank_canvas.svg
Normal file
After Width: | Height: | Size: 12 KiB |
1
dev-docs/static/img/undraw_innovative.svg
Normal file
After Width: | Height: | Size: 5.4 KiB |
7
dev-docs/tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
// This file is not used in compilation. It is here just for a nice editor experience.
|
||||||
|
"extends": "@tsconfig/docusaurus/tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": "."
|
||||||
|
}
|
||||||
|
}
|
7489
dev-docs/yarn.lock
Normal file
50
package.json
@@ -23,17 +23,18 @@
|
|||||||
"@sentry/integrations": "6.2.5",
|
"@sentry/integrations": "6.2.5",
|
||||||
"@testing-library/jest-dom": "5.16.2",
|
"@testing-library/jest-dom": "5.16.2",
|
||||||
"@testing-library/react": "12.1.5",
|
"@testing-library/react": "12.1.5",
|
||||||
"@tldraw/vec": "1.4.3",
|
"@tldraw/vec": "1.7.1",
|
||||||
"@types/jest": "27.4.0",
|
"@types/jest": "27.4.0",
|
||||||
"@types/pica": "5.1.3",
|
"@types/pica": "5.1.3",
|
||||||
"@types/react": "17.0.39",
|
"@types/react": "18.0.15",
|
||||||
"@types/react-dom": "17.0.11",
|
"@types/react-dom": "18.0.6",
|
||||||
"@types/socket.io-client": "1.4.36",
|
"@types/socket.io-client": "1.4.36",
|
||||||
"browser-fs-access": "0.29.1",
|
"browser-fs-access": "0.29.1",
|
||||||
"clsx": "1.1.1",
|
"clsx": "1.1.1",
|
||||||
|
"cross-env": "7.0.3",
|
||||||
"fake-indexeddb": "3.1.7",
|
"fake-indexeddb": "3.1.7",
|
||||||
"firebase": "8.3.3",
|
"firebase": "8.3.3",
|
||||||
"i18next-browser-languagedetector": "6.1.2",
|
"i18next-browser-languagedetector": "6.1.4",
|
||||||
"idb-keyval": "6.0.3",
|
"idb-keyval": "6.0.3",
|
||||||
"image-blob-reduce": "3.0.1",
|
"image-blob-reduce": "3.0.1",
|
||||||
"jotai": "1.6.4",
|
"jotai": "1.6.4",
|
||||||
@@ -41,40 +42,51 @@
|
|||||||
"nanoid": "3.3.3",
|
"nanoid": "3.3.3",
|
||||||
"open-color": "1.9.1",
|
"open-color": "1.9.1",
|
||||||
"pako": "1.0.11",
|
"pako": "1.0.11",
|
||||||
"perfect-freehand": "1.0.16",
|
"perfect-freehand": "1.2.0",
|
||||||
|
"pica": "7.1.1",
|
||||||
"png-chunk-text": "1.0.0",
|
"png-chunk-text": "1.0.0",
|
||||||
"png-chunks-encode": "1.0.0",
|
"png-chunks-encode": "1.0.0",
|
||||||
"png-chunks-extract": "1.0.0",
|
"png-chunks-extract": "1.0.0",
|
||||||
"points-on-curve": "0.2.0",
|
"points-on-curve": "0.2.0",
|
||||||
"pwacompat": "2.0.17",
|
"pwacompat": "2.0.17",
|
||||||
"react": "17.0.2",
|
"react": "18.2.0",
|
||||||
"react-dom": "17.0.2",
|
"react-dom": "18.2.0",
|
||||||
"react-scripts": "4.0.3",
|
"react-scripts": "5.0.1",
|
||||||
"roughjs": "4.5.2",
|
"roughjs": "4.5.2",
|
||||||
"sass": "1.51.0",
|
"sass": "1.51.0",
|
||||||
"socket.io-client": "2.3.1",
|
"socket.io-client": "2.3.1",
|
||||||
"typescript": "4.5.5"
|
"typescript": "4.9.4",
|
||||||
|
"workbox-background-sync": "^6.5.4",
|
||||||
|
"workbox-broadcast-update": "^6.5.4",
|
||||||
|
"workbox-cacheable-response": "^6.5.4",
|
||||||
|
"workbox-core": "^6.5.4",
|
||||||
|
"workbox-expiration": "^6.5.4",
|
||||||
|
"workbox-google-analytics": "^6.5.4",
|
||||||
|
"workbox-navigation-preload": "^6.5.4",
|
||||||
|
"workbox-precaching": "^6.5.4",
|
||||||
|
"workbox-range-requests": "^6.5.4",
|
||||||
|
"workbox-routing": "^6.5.4",
|
||||||
|
"workbox-strategies": "^6.5.4",
|
||||||
|
"workbox-streams": "^6.5.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@excalidraw/eslint-config": "1.0.0",
|
"@excalidraw/eslint-config": "1.0.0",
|
||||||
"@excalidraw/prettier-config": "1.0.2",
|
"@excalidraw/prettier-config": "1.0.2",
|
||||||
"@types/chai": "4.3.0",
|
"@types/chai": "4.3.0",
|
||||||
"@types/lodash.throttle": "4.1.6",
|
"@types/lodash.throttle": "4.1.7",
|
||||||
"@types/pako": "1.0.3",
|
"@types/pako": "1.0.3",
|
||||||
"@types/resize-observer-browser": "0.1.6",
|
"@types/resize-observer-browser": "0.1.7",
|
||||||
"chai": "4.3.6",
|
"chai": "4.3.6",
|
||||||
"dotenv": "10.0.0",
|
"dotenv": "16.0.1",
|
||||||
"eslint-config-prettier": "8.5.0",
|
"eslint-config-prettier": "8.5.0",
|
||||||
"eslint-plugin-prettier": "3.3.1",
|
"eslint-plugin-prettier": "3.3.1",
|
||||||
|
"http-server": "14.1.1",
|
||||||
"husky": "7.0.4",
|
"husky": "7.0.4",
|
||||||
"jest-canvas-mock": "2.4.0",
|
"jest-canvas-mock": "2.4.0",
|
||||||
"lint-staged": "12.3.7",
|
"lint-staged": "12.3.7",
|
||||||
"pepjs": "0.5.3",
|
"pepjs": "0.5.3",
|
||||||
"prettier": "2.6.2",
|
"prettier": "2.6.2",
|
||||||
"rewire": "5.0.0"
|
"rewire": "6.0.0"
|
||||||
},
|
|
||||||
"resolutions": {
|
|
||||||
"@typescript-eslint/typescript-estree": "5.10.2"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.0.0"
|
"node": ">=14.0.0"
|
||||||
@@ -92,10 +104,9 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build-node": "node ./scripts/build-node.js",
|
"build-node": "node ./scripts/build-node.js",
|
||||||
"build:app:docker": "REACT_APP_DISABLE_SENTRY=true react-scripts build",
|
"build:app:docker": "REACT_APP_DISABLE_SENTRY=true react-scripts build",
|
||||||
"build:app": "REACT_APP_GIT_SHA=$VERCEL_GIT_COMMIT_SHA react-scripts build",
|
"build:app": "cross-env REACT_APP_GIT_SHA=$VERCEL_GIT_COMMIT_SHA react-scripts build",
|
||||||
"build:version": "node ./scripts/build-version.js",
|
"build:version": "node ./scripts/build-version.js",
|
||||||
"build:prebuild": "node ./scripts/prebuild.js",
|
"build": "yarn build:app && yarn build:version",
|
||||||
"build": "yarn build:prebuild && yarn build:app && yarn build:version",
|
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject",
|
||||||
"fix:code": "yarn test:code --fix",
|
"fix:code": "yarn test:code --fix",
|
||||||
"fix:other": "yarn prettier --write",
|
"fix:other": "yarn prettier --write",
|
||||||
@@ -105,6 +116,7 @@
|
|||||||
"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",
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
|
"start:production": "npm run build && npx http-server build -a localhost -p 5001 -o",
|
||||||
"test:all": "yarn test:typecheck && yarn test:code && yarn test:other && yarn test:app --watchAll=false",
|
"test:all": "yarn test:typecheck && yarn test:code && yarn test:other && yarn test:app --watchAll=false",
|
||||||
"test:app": "react-scripts test --passWithNoTests",
|
"test:app": "react-scripts test --passWithNoTests",
|
||||||
"test:code": "eslint --max-warnings=0 --ext .js,.ts,.tsx .",
|
"test:code": "eslint --max-warnings=0 --ext .js,.ts,.tsx .",
|
||||||
|
BIN
public/Assistant-Bold.woff2
Normal file
BIN
public/Assistant-Medium.woff2
Normal file
BIN
public/Assistant-Regular.woff2
Normal file
BIN
public/Assistant-SemiBold.woff2
Normal file
@@ -11,3 +11,28 @@
|
|||||||
src: url("Cascadia.woff2");
|
src: url("Cascadia.woff2");
|
||||||
font-display: swap;
|
font-display: swap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: "Assistant";
|
||||||
|
src: url("Assistant-Regular.woff2");
|
||||||
|
font-display: swap;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: "Assistant";
|
||||||
|
src: url("Assistant-Medium.woff2");
|
||||||
|
font-display: swap;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: "Assistant";
|
||||||
|
src: url("Assistant-SemiBold.woff2");
|
||||||
|
font-display: swap;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: "Assistant";
|
||||||
|
src: url("Assistant-Bold.woff2");
|
||||||
|
font-display: swap;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
@@ -8,49 +8,76 @@
|
|||||||
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"
|
||||||
/>
|
/>
|
||||||
<meta name="referrer" content="origin" />
|
<meta name="referrer" content="origin" />
|
||||||
|
|
||||||
<meta name="mobile-web-app-capable" content="yes" />
|
<meta name="mobile-web-app-capable" content="yes" />
|
||||||
|
<meta name="theme-color" content="#121212" />
|
||||||
|
|
||||||
<meta name="theme-color" content="#000" />
|
<!-- Primary Meta Tags -->
|
||||||
|
<meta
|
||||||
|
name="title"
|
||||||
|
content="Excalidraw — Collaborative whiteboarding made easy"
|
||||||
|
/>
|
||||||
|
<meta
|
||||||
|
name="description"
|
||||||
|
content="Excalidraw is a virtual collaborative whiteboard tool that lets you easily sketch diagrams that have a hand-drawn feel to them."
|
||||||
|
/>
|
||||||
|
<meta name="image" content="https://excalidraw.com/og-general-v1.png" />
|
||||||
|
|
||||||
|
<!-- Open Graph / Facebook -->
|
||||||
|
<meta property="og:site_name" content="Excalidraw" />
|
||||||
|
<meta property="og:type" content="website" />
|
||||||
|
<meta property="og:url" content="https://excalidraw.com" />
|
||||||
|
<meta
|
||||||
|
property="og:title"
|
||||||
|
content="Excalidraw — Collaborative whiteboarding made easy"
|
||||||
|
/>
|
||||||
|
<meta property="og:image:alt" content="Excalidraw logo" />
|
||||||
|
<meta
|
||||||
|
property="og:description"
|
||||||
|
content="Excalidraw is a virtual collaborative whiteboard tool that lets you easily sketch diagrams that have a hand-drawn feel to them."
|
||||||
|
/>
|
||||||
|
<meta property="og:image" content="https://excalidraw.com/og-fb-v1.png" />
|
||||||
|
|
||||||
|
<!-- Twitter -->
|
||||||
|
<meta property="twitter:card" content="summary_large_image" />
|
||||||
|
<meta property="twitter:site" content="@excalidraw" />
|
||||||
|
<meta property="twitter:url" content="https://excalidraw.com" />
|
||||||
|
<meta
|
||||||
|
property="twitter:title"
|
||||||
|
content="Excalidraw — Collaborative whiteboarding made easy"
|
||||||
|
/>
|
||||||
|
<meta
|
||||||
|
property="twitter:description"
|
||||||
|
content="Excalidraw is a virtual collaborative whiteboard tool that lets you easily sketch diagrams that have a hand-drawn feel to them."
|
||||||
|
/>
|
||||||
|
<meta
|
||||||
|
property="twitter:image"
|
||||||
|
content="https://excalidraw.com/og-twitter-v1.png"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- General tags -->
|
<!-- General tags -->
|
||||||
<meta
|
<meta
|
||||||
name="description"
|
name="description"
|
||||||
content="Excalidraw is a virtual collaborative whiteboard tool that lets you easily sketch diagrams that have a hand-drawn feel to them."
|
content="Excalidraw is a virtual collaborative whiteboard tool that lets you easily sketch diagrams that have a hand-drawn feel to them."
|
||||||
/>
|
/>
|
||||||
<meta name="image" content="og-image.png" />
|
|
||||||
|
|
||||||
<!-- OpenGraph tags -->
|
<!------------------------------------------------------------------------->
|
||||||
<meta property="og:url" content="https://excalidraw.com" />
|
<!-- to minimize white flash on load when user has dark mode enabled -->
|
||||||
<meta property="og:site_name" content="Excalidraw" />
|
<script>
|
||||||
<meta property="og:type" content="website" />
|
try {
|
||||||
<meta property="og:title" content="Excalidraw" />
|
//
|
||||||
<meta
|
const theme = window.localStorage.getItem("excalidraw-theme");
|
||||||
property="og:description"
|
if (theme === "dark") {
|
||||||
content="Excalidraw is a whiteboard tool that lets you easily sketch diagrams that have a hand-drawn feel to them."
|
document.documentElement.classList.add("dark");
|
||||||
/>
|
}
|
||||||
<!-- OG tags require an absolute url for images -->
|
} catch {}
|
||||||
<meta
|
</script>
|
||||||
property="og:image"
|
<style>
|
||||||
name="twitter:image"
|
html.dark {
|
||||||
content="https://excalidraw.com/og-image.png"
|
background-color: #121212;
|
||||||
/>
|
color: #fff;
|
||||||
<meta
|
}
|
||||||
property="og:image:secure_url"
|
</style>
|
||||||
name="twitter:image"
|
<!------------------------------------------------------------------------->
|
||||||
content="https://excalidraw.com/og-image.png"
|
|
||||||
/>
|
|
||||||
<meta property="og:image:width" content="1280" />
|
|
||||||
<meta property="og:image:height" content="669" />
|
|
||||||
<meta property="og:image:alt" content="Excalidraw logo with byline." />
|
|
||||||
|
|
||||||
<!-- Twitter Card tags -->
|
|
||||||
<meta name="twitter:card" content="summary_large_image" />
|
|
||||||
<meta name="twitter:title" content="Excalidraw" />
|
|
||||||
<meta
|
|
||||||
name="twitter:description"
|
|
||||||
content="Excalidraw is a whiteboard tool that lets you easily sketch diagrams that have a hand-drawn feel to them."
|
|
||||||
/>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Redirect Excalidraw+ users which have auto-redirect enabled.
|
// Redirect Excalidraw+ users which have auto-redirect enabled.
|
||||||
@@ -98,7 +125,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<link rel="stylesheet" href="fonts.css" type="text/css" />
|
<link rel="stylesheet" href="fonts.css" type="text/css" />
|
||||||
<% if (process.env.REACT_APP_DEV_DISABLE_LIVE_RELOAD === "true") { %>
|
<% if (process.env.REACT_APP_DEV_DISABLE_LIVE_RELOAD==="true" ) { %>
|
||||||
<script>
|
<script>
|
||||||
{
|
{
|
||||||
const _WebSocket = window.WebSocket;
|
const _WebSocket = window.WebSocket;
|
||||||
@@ -139,8 +166,8 @@
|
|||||||
body,
|
body,
|
||||||
html {
|
html {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
--ui-font: system-ui, BlinkMacSystemFont, -apple-system, Segoe UI,
|
--ui-font: Assistant, system-ui, BlinkMacSystemFont, -apple-system,
|
||||||
Roboto, Helvetica, Arial, sans-serif;
|
Segoe UI, Roboto, Helvetica, Arial, sans-serif;
|
||||||
font-family: var(--ui-font);
|
font-family: var(--ui-font);
|
||||||
-webkit-text-size-adjust: 100%;
|
-webkit-text-size-adjust: 100%;
|
||||||
|
|
||||||
@@ -155,7 +182,7 @@
|
|||||||
width: 1px;
|
width: 1px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
clip: rect(1px, 1px, 1px, 1px);
|
clip: rect(1px, 1px, 1px, 1px);
|
||||||
white-space: nowrap; /* added line */
|
white-space: nowrap;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
public/og-fb-v1.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
public/og-general-v1.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
public/og-twitter-v1.png
Normal file
After Width: | Height: | Size: 27 KiB |
@@ -1,3 +1,9 @@
|
|||||||
|
User-agent: Twitterbot
|
||||||
|
Disallow:
|
||||||
|
|
||||||
|
User-agent: facebookexternalhit
|
||||||
|
Disallow:
|
||||||
|
|
||||||
user-agent: *
|
user-agent: *
|
||||||
Allow: /$
|
Allow: /$
|
||||||
Disallow: /
|
Disallow: /
|
||||||
|
@@ -1,81 +0,0 @@
|
|||||||
// eslint-disable-next-line no-restricted-globals
|
|
||||||
// eslint-disable-next-line no-unused-expressions
|
|
||||||
|
|
||||||
/* eslint-disable no-restricted-globals */
|
|
||||||
/* global importScripts, workbox */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Welcome to your Workbox-powered service worker!
|
|
||||||
*
|
|
||||||
* You'll need to register this file in your web app and you should
|
|
||||||
* disable HTTP caching for this file too.
|
|
||||||
* See https://goo.gl/nhQhGp
|
|
||||||
*
|
|
||||||
* The rest of the code is auto-generated. Please don't update this file
|
|
||||||
* directly; instead, make changes to your Workbox build configuration
|
|
||||||
* and re-run your build process.
|
|
||||||
* See https://goo.gl/2aRDsh
|
|
||||||
*/
|
|
||||||
|
|
||||||
// in dev, `process` is undefined because this file is not compiled until build
|
|
||||||
const IS_DEVELOPMENT =
|
|
||||||
typeof process === "undefined" || process.env.NODE_ENV !== "production";
|
|
||||||
|
|
||||||
if (IS_DEVELOPMENT) {
|
|
||||||
importScripts(
|
|
||||||
"https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js",
|
|
||||||
);
|
|
||||||
workbox.setConfig({
|
|
||||||
debug: true,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
importScripts("/workbox/workbox-sw.js");
|
|
||||||
workbox.setConfig({
|
|
||||||
modulePathPrefix: "/workbox/",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
self.addEventListener("message", (event) => {
|
|
||||||
if (event.data && event.data.type === "SKIP_WAITING") {
|
|
||||||
self.skipWaiting();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
workbox.core.clientsClaim();
|
|
||||||
|
|
||||||
if (!IS_DEVELOPMENT) {
|
|
||||||
workbox.precaching.precacheAndRoute(self.__WB_MANIFEST);
|
|
||||||
|
|
||||||
workbox.routing.registerNavigationRoute(
|
|
||||||
workbox.precaching.getCacheKeyForURL("./index.html"),
|
|
||||||
{
|
|
||||||
blacklist: [/^\/_/, /\/[^/?]+\.[^/]+$/],
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cache relevant font files
|
|
||||||
workbox.routing.registerRoute(
|
|
||||||
new RegExp("/(fonts.css|.+.(ttf|woff2|otf))"),
|
|
||||||
new workbox.strategies.StaleWhileRevalidate({
|
|
||||||
cacheName: "fonts",
|
|
||||||
plugins: [new workbox.expiration.Plugin({ maxEntries: 10 })],
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
self.addEventListener("fetch", (event) => {
|
|
||||||
if (
|
|
||||||
event.request.method === "POST" &&
|
|
||||||
event.request.url.endsWith("/web-share-target")
|
|
||||||
) {
|
|
||||||
return event.respondWith(
|
|
||||||
(async () => {
|
|
||||||
const formData = await event.request.formData();
|
|
||||||
const file = formData.get("file");
|
|
||||||
const webShareTargetCache = await caches.open("web-share-target");
|
|
||||||
await webShareTargetCache.put("shared-file", new Response(file));
|
|
||||||
return Response.redirect("/?web-share-target", 303);
|
|
||||||
})(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
21
scripts/buildDocs.js
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
const { exec } = require("child_process");
|
||||||
|
|
||||||
|
// get files changed between prev and head commit
|
||||||
|
exec(`git diff --name-only HEAD^ HEAD`, async (error, stdout, stderr) => {
|
||||||
|
if (error || stderr) {
|
||||||
|
console.error(error);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
const changedFiles = stdout.trim().split("\n");
|
||||||
|
|
||||||
|
const docFiles = changedFiles.filter((file) => {
|
||||||
|
return file.indexOf("docs") >= 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!docFiles.length) {
|
||||||
|
console.info("Skipping building docs as no valid diff found");
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
// Exit code 1 to build the docs in ignoredBuildStep
|
||||||
|
process.exit(1);
|
||||||
|
});
|
@@ -15,6 +15,7 @@ const crowdinMap = {
|
|||||||
"fa-IR": "en-fa",
|
"fa-IR": "en-fa",
|
||||||
"fi-FI": "en-fi",
|
"fi-FI": "en-fi",
|
||||||
"fr-FR": "en-fr",
|
"fr-FR": "en-fr",
|
||||||
|
"gl-ES": "en-gl",
|
||||||
"he-IL": "en-he",
|
"he-IL": "en-he",
|
||||||
"hi-IN": "en-hi",
|
"hi-IN": "en-hi",
|
||||||
"hu-HU": "en-hu",
|
"hu-HU": "en-hu",
|
||||||
@@ -23,6 +24,7 @@ const crowdinMap = {
|
|||||||
"ja-JP": "en-ja",
|
"ja-JP": "en-ja",
|
||||||
"kab-KAB": "en-kab",
|
"kab-KAB": "en-kab",
|
||||||
"ko-KR": "en-ko",
|
"ko-KR": "en-ko",
|
||||||
|
"ku-TR": "en-ku",
|
||||||
"my-MM": "en-my",
|
"my-MM": "en-my",
|
||||||
"nb-NO": "en-nb",
|
"nb-NO": "en-nb",
|
||||||
"nl-NL": "en-nl",
|
"nl-NL": "en-nl",
|
||||||
@@ -36,6 +38,7 @@ const crowdinMap = {
|
|||||||
"ru-RU": "en-ru",
|
"ru-RU": "en-ru",
|
||||||
"si-LK": "en-silk",
|
"si-LK": "en-silk",
|
||||||
"sk-SK": "en-sk",
|
"sk-SK": "en-sk",
|
||||||
|
"sl-SI": "en-sl",
|
||||||
"sv-SE": "en-sv",
|
"sv-SE": "en-sv",
|
||||||
"ta-IN": "en-ta",
|
"ta-IN": "en-ta",
|
||||||
"tr-TR": "en-tr",
|
"tr-TR": "en-tr",
|
||||||
@@ -47,6 +50,8 @@ const crowdinMap = {
|
|||||||
"lv-LV": "en-lv",
|
"lv-LV": "en-lv",
|
||||||
"cs-CZ": "en-cs",
|
"cs-CZ": "en-cs",
|
||||||
"kk-KZ": "en-kk",
|
"kk-KZ": "en-kk",
|
||||||
|
"vi-VN": "en-vi",
|
||||||
|
"mr-IN": "en-mr",
|
||||||
};
|
};
|
||||||
|
|
||||||
const flags = {
|
const flags = {
|
||||||
@@ -62,6 +67,7 @@ const flags = {
|
|||||||
"fa-IR": "🇮🇷",
|
"fa-IR": "🇮🇷",
|
||||||
"fi-FI": "🇫🇮",
|
"fi-FI": "🇫🇮",
|
||||||
"fr-FR": "🇫🇷",
|
"fr-FR": "🇫🇷",
|
||||||
|
"gl-ES": "🇪🇸",
|
||||||
"he-IL": "🇮🇱",
|
"he-IL": "🇮🇱",
|
||||||
"hi-IN": "🇮🇳",
|
"hi-IN": "🇮🇳",
|
||||||
"hu-HU": "🇭🇺",
|
"hu-HU": "🇭🇺",
|
||||||
@@ -71,6 +77,7 @@ const flags = {
|
|||||||
"kab-KAB": "🏳",
|
"kab-KAB": "🏳",
|
||||||
"kk-KZ": "🇰🇿",
|
"kk-KZ": "🇰🇿",
|
||||||
"ko-KR": "🇰🇷",
|
"ko-KR": "🇰🇷",
|
||||||
|
"ku-TR": "🏳",
|
||||||
"lt-LT": "🇱🇹",
|
"lt-LT": "🇱🇹",
|
||||||
"lv-LV": "🇱🇻",
|
"lv-LV": "🇱🇻",
|
||||||
"my-MM": "🇲🇲",
|
"my-MM": "🇲🇲",
|
||||||
@@ -86,6 +93,7 @@ const flags = {
|
|||||||
"ru-RU": "🇷🇺",
|
"ru-RU": "🇷🇺",
|
||||||
"si-LK": "🇱🇰",
|
"si-LK": "🇱🇰",
|
||||||
"sk-SK": "🇸🇰",
|
"sk-SK": "🇸🇰",
|
||||||
|
"sl-SI": "🇸🇮",
|
||||||
"sv-SE": "🇸🇪",
|
"sv-SE": "🇸🇪",
|
||||||
"ta-IN": "🇮🇳",
|
"ta-IN": "🇮🇳",
|
||||||
"tr-TR": "🇹🇷",
|
"tr-TR": "🇹🇷",
|
||||||
@@ -93,6 +101,9 @@ const flags = {
|
|||||||
"zh-CN": "🇨🇳",
|
"zh-CN": "🇨🇳",
|
||||||
"zh-HK": "🇭🇰",
|
"zh-HK": "🇭🇰",
|
||||||
"zh-TW": "🇹🇼",
|
"zh-TW": "🇹🇼",
|
||||||
|
"eu-ES": "🇪🇦",
|
||||||
|
"vi-VN": "🇻🇳",
|
||||||
|
"mr-IN": "🇮🇳",
|
||||||
};
|
};
|
||||||
|
|
||||||
const languages = {
|
const languages = {
|
||||||
@@ -109,6 +120,7 @@ const languages = {
|
|||||||
"fa-IR": "فارسی",
|
"fa-IR": "فارسی",
|
||||||
"fi-FI": "Suomi",
|
"fi-FI": "Suomi",
|
||||||
"fr-FR": "Français",
|
"fr-FR": "Français",
|
||||||
|
"gl-ES": "Galego",
|
||||||
"he-IL": "עברית",
|
"he-IL": "עברית",
|
||||||
"hi-IN": "हिन्दी",
|
"hi-IN": "हिन्दी",
|
||||||
"hu-HU": "Magyar",
|
"hu-HU": "Magyar",
|
||||||
@@ -118,6 +130,7 @@ const languages = {
|
|||||||
"kab-KAB": "Taqbaylit",
|
"kab-KAB": "Taqbaylit",
|
||||||
"kk-KZ": "Қазақ тілі",
|
"kk-KZ": "Қазақ тілі",
|
||||||
"ko-KR": "한국어",
|
"ko-KR": "한국어",
|
||||||
|
"ku-TR": "Kurdî",
|
||||||
"lt-LT": "Lietuvių",
|
"lt-LT": "Lietuvių",
|
||||||
"lv-LV": "Latviešu",
|
"lv-LV": "Latviešu",
|
||||||
"my-MM": "Burmese",
|
"my-MM": "Burmese",
|
||||||
@@ -133,6 +146,7 @@ const languages = {
|
|||||||
"ru-RU": "Русский",
|
"ru-RU": "Русский",
|
||||||
"si-LK": "සිංහල",
|
"si-LK": "සිංහල",
|
||||||
"sk-SK": "Slovenčina",
|
"sk-SK": "Slovenčina",
|
||||||
|
"sl-SI": "Slovenščina",
|
||||||
"sv-SE": "Svenska",
|
"sv-SE": "Svenska",
|
||||||
"ta-IN": "Tamil",
|
"ta-IN": "Tamil",
|
||||||
"tr-TR": "Türkçe",
|
"tr-TR": "Türkçe",
|
||||||
@@ -140,6 +154,8 @@ const languages = {
|
|||||||
"zh-CN": "简体中文",
|
"zh-CN": "简体中文",
|
||||||
"zh-HK": "繁體中文 (香港)",
|
"zh-HK": "繁體中文 (香港)",
|
||||||
"zh-TW": "繁體中文",
|
"zh-TW": "繁體中文",
|
||||||
|
"vi-VN": "Tiếng Việt",
|
||||||
|
"mr-IN": "मराठी",
|
||||||
};
|
};
|
||||||
|
|
||||||
const percentages = fs.readFileSync(
|
const percentages = fs.readFileSync(
|
||||||
|
@@ -1,20 +0,0 @@
|
|||||||
const fs = require("fs");
|
|
||||||
|
|
||||||
// for development purposes we want to have the service-worker.js file
|
|
||||||
// accessible from the public folder. On build though, we need to compile it
|
|
||||||
// and CRA expects that file to be in src/ folder.
|
|
||||||
const moveServiceWorkerScript = () => {
|
|
||||||
const oldPath = "./public/service-worker.js";
|
|
||||||
const newPath = "./src/service-worker.js";
|
|
||||||
|
|
||||||
fs.rename(oldPath, newPath, (error) => {
|
|
||||||
if (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
console.info("public/service-worker.js moved to src/");
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
moveServiceWorkerScript();
|
|
@@ -42,7 +42,7 @@ export const actionAddToLibrary = register({
|
|||||||
commitToHistory: false,
|
commitToHistory: false,
|
||||||
appState: {
|
appState: {
|
||||||
...appState,
|
...appState,
|
||||||
toastMessage: t("toast.addedToLibrary"),
|
toast: { message: t("toast.addedToLibrary") },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
@@ -60,7 +60,7 @@ export const actionAlignTop = register({
|
|||||||
<ToolButton
|
<ToolButton
|
||||||
hidden={!enableActionGroup(elements, appState)}
|
hidden={!enableActionGroup(elements, appState)}
|
||||||
type="button"
|
type="button"
|
||||||
icon={<AlignTopIcon theme={appState.theme} />}
|
icon={AlignTopIcon}
|
||||||
onClick={() => updateData(null)}
|
onClick={() => updateData(null)}
|
||||||
title={`${t("labels.alignTop")} — ${getShortcutKey(
|
title={`${t("labels.alignTop")} — ${getShortcutKey(
|
||||||
"CtrlOrCmd+Shift+Up",
|
"CtrlOrCmd+Shift+Up",
|
||||||
@@ -90,7 +90,7 @@ export const actionAlignBottom = register({
|
|||||||
<ToolButton
|
<ToolButton
|
||||||
hidden={!enableActionGroup(elements, appState)}
|
hidden={!enableActionGroup(elements, appState)}
|
||||||
type="button"
|
type="button"
|
||||||
icon={<AlignBottomIcon theme={appState.theme} />}
|
icon={AlignBottomIcon}
|
||||||
onClick={() => updateData(null)}
|
onClick={() => updateData(null)}
|
||||||
title={`${t("labels.alignBottom")} — ${getShortcutKey(
|
title={`${t("labels.alignBottom")} — ${getShortcutKey(
|
||||||
"CtrlOrCmd+Shift+Down",
|
"CtrlOrCmd+Shift+Down",
|
||||||
@@ -120,7 +120,7 @@ export const actionAlignLeft = register({
|
|||||||
<ToolButton
|
<ToolButton
|
||||||
hidden={!enableActionGroup(elements, appState)}
|
hidden={!enableActionGroup(elements, appState)}
|
||||||
type="button"
|
type="button"
|
||||||
icon={<AlignLeftIcon theme={appState.theme} />}
|
icon={AlignLeftIcon}
|
||||||
onClick={() => updateData(null)}
|
onClick={() => updateData(null)}
|
||||||
title={`${t("labels.alignLeft")} — ${getShortcutKey(
|
title={`${t("labels.alignLeft")} — ${getShortcutKey(
|
||||||
"CtrlOrCmd+Shift+Left",
|
"CtrlOrCmd+Shift+Left",
|
||||||
@@ -151,7 +151,7 @@ export const actionAlignRight = register({
|
|||||||
<ToolButton
|
<ToolButton
|
||||||
hidden={!enableActionGroup(elements, appState)}
|
hidden={!enableActionGroup(elements, appState)}
|
||||||
type="button"
|
type="button"
|
||||||
icon={<AlignRightIcon theme={appState.theme} />}
|
icon={AlignRightIcon}
|
||||||
onClick={() => updateData(null)}
|
onClick={() => updateData(null)}
|
||||||
title={`${t("labels.alignRight")} — ${getShortcutKey(
|
title={`${t("labels.alignRight")} — ${getShortcutKey(
|
||||||
"CtrlOrCmd+Shift+Right",
|
"CtrlOrCmd+Shift+Right",
|
||||||
@@ -180,7 +180,7 @@ export const actionAlignVerticallyCentered = register({
|
|||||||
<ToolButton
|
<ToolButton
|
||||||
hidden={!enableActionGroup(elements, appState)}
|
hidden={!enableActionGroup(elements, appState)}
|
||||||
type="button"
|
type="button"
|
||||||
icon={<CenterVerticallyIcon theme={appState.theme} />}
|
icon={CenterVerticallyIcon}
|
||||||
onClick={() => updateData(null)}
|
onClick={() => updateData(null)}
|
||||||
title={t("labels.centerVertically")}
|
title={t("labels.centerVertically")}
|
||||||
aria-label={t("labels.centerVertically")}
|
aria-label={t("labels.centerVertically")}
|
||||||
@@ -206,7 +206,7 @@ export const actionAlignHorizontallyCentered = register({
|
|||||||
<ToolButton
|
<ToolButton
|
||||||
hidden={!enableActionGroup(elements, appState)}
|
hidden={!enableActionGroup(elements, appState)}
|
||||||
type="button"
|
type="button"
|
||||||
icon={<CenterHorizontallyIcon theme={appState.theme} />}
|
icon={CenterHorizontallyIcon}
|
||||||
onClick={() => updateData(null)}
|
onClick={() => updateData(null)}
|
||||||
title={t("labels.centerHorizontally")}
|
title={t("labels.centerHorizontally")}
|
||||||
aria-label={t("labels.centerHorizontally")}
|
aria-label={t("labels.centerHorizontally")}
|
||||||
|
@@ -6,6 +6,10 @@ import {
|
|||||||
measureText,
|
measureText,
|
||||||
redrawTextBoundingBox,
|
redrawTextBoundingBox,
|
||||||
} from "../element/textElement";
|
} from "../element/textElement";
|
||||||
|
import {
|
||||||
|
getOriginalContainerHeightFromCache,
|
||||||
|
resetOriginalContainerCache,
|
||||||
|
} from "../element/textWysiwyg";
|
||||||
import {
|
import {
|
||||||
hasBoundTextElement,
|
hasBoundTextElement,
|
||||||
isTextBindableContainer,
|
isTextBindableContainer,
|
||||||
@@ -38,6 +42,11 @@ export const actionUnbindText = register({
|
|||||||
boundTextElement.originalText,
|
boundTextElement.originalText,
|
||||||
getFontString(boundTextElement),
|
getFontString(boundTextElement),
|
||||||
);
|
);
|
||||||
|
const originalContainerHeight = getOriginalContainerHeightFromCache(
|
||||||
|
element.id,
|
||||||
|
);
|
||||||
|
resetOriginalContainerCache(element.id);
|
||||||
|
|
||||||
mutateElement(boundTextElement as ExcalidrawTextElement, {
|
mutateElement(boundTextElement as ExcalidrawTextElement, {
|
||||||
containerId: null,
|
containerId: null,
|
||||||
width,
|
width,
|
||||||
@@ -49,6 +58,9 @@ export const actionUnbindText = register({
|
|||||||
boundElements: element.boundElements?.filter(
|
boundElements: element.boundElements?.filter(
|
||||||
(ele) => ele.id !== boundTextElement.id,
|
(ele) => ele.id !== boundTextElement.id,
|
||||||
),
|
),
|
||||||
|
height: originalContainerHeight
|
||||||
|
? originalContainerHeight
|
||||||
|
: element.height,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -1,8 +1,13 @@
|
|||||||
import { ColorPicker } from "../components/ColorPicker";
|
import { ColorPicker } from "../components/ColorPicker";
|
||||||
import { eraser, zoomIn, zoomOut } from "../components/icons";
|
import {
|
||||||
|
eraser,
|
||||||
|
MoonIcon,
|
||||||
|
SunIcon,
|
||||||
|
ZoomInIcon,
|
||||||
|
ZoomOutIcon,
|
||||||
|
} from "../components/icons";
|
||||||
import { ToolButton } from "../components/ToolButton";
|
import { ToolButton } from "../components/ToolButton";
|
||||||
import { DarkModeToggle } from "../components/DarkModeToggle";
|
import { MIN_ZOOM, THEME, ZOOM_STEP } from "../constants";
|
||||||
import { THEME, ZOOM_STEP } from "../constants";
|
|
||||||
import { getCommonBounds, getNonDeletedElements } from "../element";
|
import { getCommonBounds, getNonDeletedElements } from "../element";
|
||||||
import { ExcalidrawElement } from "../element/types";
|
import { ExcalidrawElement } from "../element/types";
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
@@ -18,6 +23,8 @@ import { newElementWith } from "../element/mutateElement";
|
|||||||
import { getDefaultAppState, isEraserActive } from "../appState";
|
import { getDefaultAppState, isEraserActive } from "../appState";
|
||||||
import ClearCanvas from "../components/ClearCanvas";
|
import ClearCanvas from "../components/ClearCanvas";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
import MenuItem from "../components/MenuItem";
|
||||||
|
import { getShortcutFromShortcutName } from "./shortcuts";
|
||||||
|
|
||||||
export const actionChangeViewBackgroundColor = register({
|
export const actionChangeViewBackgroundColor = register({
|
||||||
name: "changeViewBackgroundColor",
|
name: "changeViewBackgroundColor",
|
||||||
@@ -83,6 +90,7 @@ export const actionClearCanvas = register({
|
|||||||
|
|
||||||
export const actionZoomIn = register({
|
export const actionZoomIn = register({
|
||||||
name: "zoomIn",
|
name: "zoomIn",
|
||||||
|
viewMode: true,
|
||||||
trackEvent: { category: "canvas" },
|
trackEvent: { category: "canvas" },
|
||||||
perform: (_elements, appState, _, app) => {
|
perform: (_elements, appState, _, app) => {
|
||||||
return {
|
return {
|
||||||
@@ -103,13 +111,13 @@ export const actionZoomIn = register({
|
|||||||
PanelComponent: ({ updateData }) => (
|
PanelComponent: ({ updateData }) => (
|
||||||
<ToolButton
|
<ToolButton
|
||||||
type="button"
|
type="button"
|
||||||
icon={zoomIn}
|
className="zoom-in-button zoom-button"
|
||||||
|
icon={ZoomInIcon}
|
||||||
title={`${t("buttons.zoomIn")} — ${getShortcutKey("CtrlOrCmd++")}`}
|
title={`${t("buttons.zoomIn")} — ${getShortcutKey("CtrlOrCmd++")}`}
|
||||||
aria-label={t("buttons.zoomIn")}
|
aria-label={t("buttons.zoomIn")}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
updateData(null);
|
updateData(null);
|
||||||
}}
|
}}
|
||||||
size="small"
|
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
keyTest: (event) =>
|
keyTest: (event) =>
|
||||||
@@ -119,6 +127,7 @@ export const actionZoomIn = register({
|
|||||||
|
|
||||||
export const actionZoomOut = register({
|
export const actionZoomOut = register({
|
||||||
name: "zoomOut",
|
name: "zoomOut",
|
||||||
|
viewMode: true,
|
||||||
trackEvent: { category: "canvas" },
|
trackEvent: { category: "canvas" },
|
||||||
perform: (_elements, appState, _, app) => {
|
perform: (_elements, appState, _, app) => {
|
||||||
return {
|
return {
|
||||||
@@ -139,13 +148,13 @@ export const actionZoomOut = register({
|
|||||||
PanelComponent: ({ updateData }) => (
|
PanelComponent: ({ updateData }) => (
|
||||||
<ToolButton
|
<ToolButton
|
||||||
type="button"
|
type="button"
|
||||||
icon={zoomOut}
|
className="zoom-out-button zoom-button"
|
||||||
|
icon={ZoomOutIcon}
|
||||||
title={`${t("buttons.zoomOut")} — ${getShortcutKey("CtrlOrCmd+-")}`}
|
title={`${t("buttons.zoomOut")} — ${getShortcutKey("CtrlOrCmd+-")}`}
|
||||||
aria-label={t("buttons.zoomOut")}
|
aria-label={t("buttons.zoomOut")}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
updateData(null);
|
updateData(null);
|
||||||
}}
|
}}
|
||||||
size="small"
|
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
keyTest: (event) =>
|
keyTest: (event) =>
|
||||||
@@ -155,6 +164,7 @@ export const actionZoomOut = register({
|
|||||||
|
|
||||||
export const actionResetZoom = register({
|
export const actionResetZoom = register({
|
||||||
name: "resetZoom",
|
name: "resetZoom",
|
||||||
|
viewMode: true,
|
||||||
trackEvent: { category: "canvas" },
|
trackEvent: { category: "canvas" },
|
||||||
perform: (_elements, appState, _, app) => {
|
perform: (_elements, appState, _, app) => {
|
||||||
return {
|
return {
|
||||||
@@ -176,13 +186,12 @@ export const actionResetZoom = register({
|
|||||||
<Tooltip label={t("buttons.resetZoom")} style={{ height: "100%" }}>
|
<Tooltip label={t("buttons.resetZoom")} style={{ height: "100%" }}>
|
||||||
<ToolButton
|
<ToolButton
|
||||||
type="button"
|
type="button"
|
||||||
className="reset-zoom-button"
|
className="reset-zoom-button zoom-button"
|
||||||
title={t("buttons.resetZoom")}
|
title={t("buttons.resetZoom")}
|
||||||
aria-label={t("buttons.resetZoom")}
|
aria-label={t("buttons.resetZoom")}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
updateData(null);
|
updateData(null);
|
||||||
}}
|
}}
|
||||||
size="small"
|
|
||||||
>
|
>
|
||||||
{(appState.zoom.value * 100).toFixed(0)}%
|
{(appState.zoom.value * 100).toFixed(0)}%
|
||||||
</ToolButton>
|
</ToolButton>
|
||||||
@@ -206,7 +215,7 @@ const zoomValueToFitBoundsOnViewport = (
|
|||||||
const zoomAdjustedToSteps =
|
const zoomAdjustedToSteps =
|
||||||
Math.floor(smallestZoomValue / ZOOM_STEP) * ZOOM_STEP;
|
Math.floor(smallestZoomValue / ZOOM_STEP) * ZOOM_STEP;
|
||||||
const clampedZoomValueToFitElements = Math.min(
|
const clampedZoomValueToFitElements = Math.min(
|
||||||
Math.max(zoomAdjustedToSteps, ZOOM_STEP),
|
Math.max(zoomAdjustedToSteps, MIN_ZOOM),
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
return clampedZoomValueToFitElements as NormalizedZoomValue;
|
return clampedZoomValueToFitElements as NormalizedZoomValue;
|
||||||
@@ -265,6 +274,7 @@ export const actionZoomToSelected = register({
|
|||||||
|
|
||||||
export const actionZoomToFit = register({
|
export const actionZoomToFit = register({
|
||||||
name: "zoomToFit",
|
name: "zoomToFit",
|
||||||
|
viewMode: true,
|
||||||
trackEvent: { category: "canvas" },
|
trackEvent: { category: "canvas" },
|
||||||
perform: (elements, appState) => zoomToFitElements(elements, appState, false),
|
perform: (elements, appState) => zoomToFitElements(elements, appState, false),
|
||||||
keyTest: (event) =>
|
keyTest: (event) =>
|
||||||
@@ -276,6 +286,7 @@ export const actionZoomToFit = register({
|
|||||||
|
|
||||||
export const actionToggleTheme = register({
|
export const actionToggleTheme = register({
|
||||||
name: "toggleTheme",
|
name: "toggleTheme",
|
||||||
|
viewMode: true,
|
||||||
trackEvent: { category: "canvas" },
|
trackEvent: { category: "canvas" },
|
||||||
perform: (_, appState, value) => {
|
perform: (_, appState, value) => {
|
||||||
return {
|
return {
|
||||||
@@ -288,14 +299,19 @@ export const actionToggleTheme = register({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
PanelComponent: ({ appState, updateData }) => (
|
PanelComponent: ({ appState, updateData }) => (
|
||||||
<div style={{ marginInlineStart: "0.25rem" }}>
|
<MenuItem
|
||||||
<DarkModeToggle
|
label={
|
||||||
value={appState.theme}
|
appState.theme === "dark"
|
||||||
onChange={(theme) => {
|
? t("buttons.lightMode")
|
||||||
updateData(theme);
|
: t("buttons.darkMode")
|
||||||
}}
|
}
|
||||||
/>
|
onClick={() => {
|
||||||
</div>
|
updateData(appState.theme === THEME.LIGHT ? THEME.DARK : THEME.LIGHT);
|
||||||
|
}}
|
||||||
|
icon={appState.theme === "dark" ? SunIcon : MoonIcon}
|
||||||
|
dataTestId="toggle-dark-mode"
|
||||||
|
shortcut={getShortcutFromShortcutName("toggleTheme")}
|
||||||
|
/>
|
||||||
),
|
),
|
||||||
keyTest: (event) => event.altKey && event.shiftKey && event.code === CODES.D,
|
keyTest: (event) => event.altKey && event.shiftKey && event.code === CODES.D,
|
||||||
});
|
});
|
||||||
|
@@ -3,6 +3,7 @@ import { register } from "./register";
|
|||||||
import {
|
import {
|
||||||
copyTextToSystemClipboard,
|
copyTextToSystemClipboard,
|
||||||
copyToClipboard,
|
copyToClipboard,
|
||||||
|
probablySupportsClipboardBlob,
|
||||||
probablySupportsClipboardWriteText,
|
probablySupportsClipboardWriteText,
|
||||||
} from "../clipboard";
|
} from "../clipboard";
|
||||||
import { actionDeleteSelected } from "./actionDeleteSelected";
|
import { actionDeleteSelected } from "./actionDeleteSelected";
|
||||||
@@ -23,11 +24,31 @@ export const actionCopy = register({
|
|||||||
commitToHistory: false,
|
commitToHistory: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
contextItemPredicate: (elements, appState, appProps, app) => {
|
||||||
|
return app.device.isMobile && !!navigator.clipboard;
|
||||||
|
},
|
||||||
contextItemLabel: "labels.copy",
|
contextItemLabel: "labels.copy",
|
||||||
// don't supply a shortcut since we handle this conditionally via onCopy event
|
// don't supply a shortcut since we handle this conditionally via onCopy event
|
||||||
keyTest: undefined,
|
keyTest: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const actionPaste = register({
|
||||||
|
name: "paste",
|
||||||
|
trackEvent: { category: "element" },
|
||||||
|
perform: (elements: any, appStates: any, data, app) => {
|
||||||
|
app.pasteFromClipboard(null);
|
||||||
|
return {
|
||||||
|
commitToHistory: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
contextItemPredicate: (elements, appState, appProps, app) => {
|
||||||
|
return app.device.isMobile && !!navigator.clipboard;
|
||||||
|
},
|
||||||
|
contextItemLabel: "labels.paste",
|
||||||
|
// don't supply a shortcut since we handle this conditionally via onCopy event
|
||||||
|
keyTest: undefined,
|
||||||
|
});
|
||||||
|
|
||||||
export const actionCut = register({
|
export const actionCut = register({
|
||||||
name: "cut",
|
name: "cut",
|
||||||
trackEvent: { category: "element" },
|
trackEvent: { category: "element" },
|
||||||
@@ -35,8 +56,11 @@ export const actionCut = register({
|
|||||||
actionCopy.perform(elements, appState, data, app);
|
actionCopy.perform(elements, appState, data, app);
|
||||||
return actionDeleteSelected.perform(elements, appState);
|
return actionDeleteSelected.perform(elements, appState);
|
||||||
},
|
},
|
||||||
|
contextItemPredicate: (elements, appState, appProps, app) => {
|
||||||
|
return app.device.isMobile && !!navigator.clipboard;
|
||||||
|
},
|
||||||
contextItemLabel: "labels.cut",
|
contextItemLabel: "labels.cut",
|
||||||
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.code === CODES.X,
|
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.key === KEYS.X,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const actionCopyAsSvg = register({
|
export const actionCopyAsSvg = register({
|
||||||
@@ -77,6 +101,9 @@ export const actionCopyAsSvg = register({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
contextItemPredicate: (elements) => {
|
||||||
|
return probablySupportsClipboardWriteText && elements.length > 0;
|
||||||
|
},
|
||||||
contextItemLabel: "labels.copyAsSvg",
|
contextItemLabel: "labels.copyAsSvg",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -107,14 +134,16 @@ export const actionCopyAsPng = register({
|
|||||||
return {
|
return {
|
||||||
appState: {
|
appState: {
|
||||||
...appState,
|
...appState,
|
||||||
toastMessage: t("toast.copyToClipboardAsPng", {
|
toast: {
|
||||||
exportSelection: selectedElements.length
|
message: t("toast.copyToClipboardAsPng", {
|
||||||
? t("toast.selection")
|
exportSelection: selectedElements.length
|
||||||
: t("toast.canvas"),
|
? t("toast.selection")
|
||||||
exportColorScheme: appState.exportWithDarkMode
|
: t("toast.canvas"),
|
||||||
? t("buttons.darkMode")
|
exportColorScheme: appState.exportWithDarkMode
|
||||||
: t("buttons.lightMode"),
|
? t("buttons.darkMode")
|
||||||
}),
|
: t("buttons.lightMode"),
|
||||||
|
}),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
commitToHistory: false,
|
commitToHistory: false,
|
||||||
};
|
};
|
||||||
@@ -129,6 +158,9 @@ export const actionCopyAsPng = register({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
contextItemPredicate: (elements) => {
|
||||||
|
return probablySupportsClipboardBlob && elements.length > 0;
|
||||||
|
},
|
||||||
contextItemLabel: "labels.copyAsPng",
|
contextItemLabel: "labels.copyAsPng",
|
||||||
keyTest: (event) => event.code === CODES.C && event.altKey && event.shiftKey,
|
keyTest: (event) => event.code === CODES.C && event.altKey && event.shiftKey,
|
||||||
});
|
});
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import { isSomeElementSelected } from "../scene";
|
import { isSomeElementSelected } from "../scene";
|
||||||
import { KEYS } from "../keys";
|
import { KEYS } from "../keys";
|
||||||
import { ToolButton } from "../components/ToolButton";
|
import { ToolButton } from "../components/ToolButton";
|
||||||
import { trash } from "../components/icons";
|
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { register } from "./register";
|
import { register } from "./register";
|
||||||
import { getNonDeletedElements } from "../element";
|
import { getNonDeletedElements } from "../element";
|
||||||
@@ -13,6 +12,7 @@ import { LinearElementEditor } from "../element/linearElementEditor";
|
|||||||
import { fixBindingsAfterDeletion } from "../element/binding";
|
import { fixBindingsAfterDeletion } from "../element/binding";
|
||||||
import { isBoundToContainer } from "../element/typeChecks";
|
import { isBoundToContainer } from "../element/typeChecks";
|
||||||
import { updateActiveTool } from "../utils";
|
import { updateActiveTool } from "../utils";
|
||||||
|
import { TrashIcon } from "../components/icons";
|
||||||
|
|
||||||
const deleteSelectedElements = (
|
const deleteSelectedElements = (
|
||||||
elements: readonly ExcalidrawElement[],
|
elements: readonly ExcalidrawElement[],
|
||||||
@@ -72,13 +72,22 @@ export const actionDeleteSelected = register({
|
|||||||
if (!element) {
|
if (!element) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (
|
// case: no point selected → do nothing, as deleting the whole element
|
||||||
// case: no point selected → delete whole element
|
// is most likely a mistake, where you wanted to delete a specific point
|
||||||
selectedPointsIndices == null ||
|
// but failed to select it (or you thought it's selected, while it was
|
||||||
// case: deleting last remaining point
|
// only in a hover state)
|
||||||
element.points.length < 2
|
if (selectedPointsIndices == null) {
|
||||||
) {
|
return false;
|
||||||
const nextElements = elements.filter((el) => el.id !== element.id);
|
}
|
||||||
|
|
||||||
|
// case: deleting last remaining point
|
||||||
|
if (element.points.length < 2) {
|
||||||
|
const nextElements = elements.map((el) => {
|
||||||
|
if (el.id === element.id) {
|
||||||
|
return newElementWith(el, { isDeleted: true });
|
||||||
|
}
|
||||||
|
return el;
|
||||||
|
});
|
||||||
const nextAppState = handleGroupEditingState(appState, nextElements);
|
const nextAppState = handleGroupEditingState(appState, nextElements);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -149,7 +158,7 @@ export const actionDeleteSelected = register({
|
|||||||
PanelComponent: ({ elements, appState, updateData }) => (
|
PanelComponent: ({ elements, appState, updateData }) => (
|
||||||
<ToolButton
|
<ToolButton
|
||||||
type="button"
|
type="button"
|
||||||
icon={trash}
|
icon={TrashIcon}
|
||||||
title={t("labels.delete")}
|
title={t("labels.delete")}
|
||||||
aria-label={t("labels.delete")}
|
aria-label={t("labels.delete")}
|
||||||
onClick={() => updateData(null)}
|
onClick={() => updateData(null)}
|
||||||
|
@@ -56,7 +56,7 @@ export const distributeHorizontally = register({
|
|||||||
<ToolButton
|
<ToolButton
|
||||||
hidden={!enableActionGroup(elements, appState)}
|
hidden={!enableActionGroup(elements, appState)}
|
||||||
type="button"
|
type="button"
|
||||||
icon={<DistributeHorizontallyIcon theme={appState.theme} />}
|
icon={DistributeHorizontallyIcon}
|
||||||
onClick={() => updateData(null)}
|
onClick={() => updateData(null)}
|
||||||
title={`${t("labels.distributeHorizontally")} — ${getShortcutKey(
|
title={`${t("labels.distributeHorizontally")} — ${getShortcutKey(
|
||||||
"Alt+H",
|
"Alt+H",
|
||||||
@@ -86,7 +86,7 @@ export const distributeVertically = register({
|
|||||||
<ToolButton
|
<ToolButton
|
||||||
hidden={!enableActionGroup(elements, appState)}
|
hidden={!enableActionGroup(elements, appState)}
|
||||||
type="button"
|
type="button"
|
||||||
icon={<DistributeVerticallyIcon theme={appState.theme} />}
|
icon={DistributeVerticallyIcon}
|
||||||
onClick={() => updateData(null)}
|
onClick={() => updateData(null)}
|
||||||
title={`${t("labels.distributeVertically")} — ${getShortcutKey("Alt+V")}`}
|
title={`${t("labels.distributeVertically")} — ${getShortcutKey("Alt+V")}`}
|
||||||
aria-label={t("labels.distributeVertically")}
|
aria-label={t("labels.distributeVertically")}
|
||||||
|
@@ -4,7 +4,6 @@ import { ExcalidrawElement } from "../element/types";
|
|||||||
import { duplicateElement, getNonDeletedElements } from "../element";
|
import { duplicateElement, getNonDeletedElements } from "../element";
|
||||||
import { getSelectedElements, isSomeElementSelected } from "../scene";
|
import { getSelectedElements, isSomeElementSelected } from "../scene";
|
||||||
import { ToolButton } from "../components/ToolButton";
|
import { ToolButton } from "../components/ToolButton";
|
||||||
import { clone } from "../components/icons";
|
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { arrayToMap, getShortcutKey } from "../utils";
|
import { arrayToMap, getShortcutKey } from "../utils";
|
||||||
import { LinearElementEditor } from "../element/linearElementEditor";
|
import { LinearElementEditor } from "../element/linearElementEditor";
|
||||||
@@ -19,6 +18,7 @@ import { ActionResult } from "./types";
|
|||||||
import { GRID_SIZE } from "../constants";
|
import { GRID_SIZE } from "../constants";
|
||||||
import { bindTextToShapeAfterDuplication } from "../element/textElement";
|
import { bindTextToShapeAfterDuplication } from "../element/textElement";
|
||||||
import { isBoundToContainer } from "../element/typeChecks";
|
import { isBoundToContainer } from "../element/typeChecks";
|
||||||
|
import { DuplicateIcon } from "../components/icons";
|
||||||
|
|
||||||
export const actionDuplicateSelection = register({
|
export const actionDuplicateSelection = register({
|
||||||
name: "duplicateSelection",
|
name: "duplicateSelection",
|
||||||
@@ -49,7 +49,7 @@ export const actionDuplicateSelection = register({
|
|||||||
PanelComponent: ({ elements, appState, updateData }) => (
|
PanelComponent: ({ elements, appState, updateData }) => (
|
||||||
<ToolButton
|
<ToolButton
|
||||||
type="button"
|
type="button"
|
||||||
icon={clone}
|
icon={DuplicateIcon}
|
||||||
title={`${t("labels.duplicateSelection")} — ${getShortcutKey(
|
title={`${t("labels.duplicateSelection")} — ${getShortcutKey(
|
||||||
"CtrlOrCmd+D",
|
"CtrlOrCmd+D",
|
||||||
)}`}
|
)}`}
|
||||||
@@ -128,12 +128,15 @@ const duplicateElements = (
|
|||||||
{
|
{
|
||||||
...appState,
|
...appState,
|
||||||
selectedGroupIds: {},
|
selectedGroupIds: {},
|
||||||
selectedElementIds: newElements.reduce((acc, element) => {
|
selectedElementIds: newElements.reduce(
|
||||||
if (!isBoundToContainer(element)) {
|
(acc: Record<ExcalidrawElement["id"], true>, element) => {
|
||||||
acc[element.id] = true;
|
if (!isBoundToContainer(element)) {
|
||||||
}
|
acc[element.id] = true;
|
||||||
return acc;
|
}
|
||||||
}, {} as any),
|
return acc;
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
),
|
||||||
},
|
},
|
||||||
getNonDeletedElements(finalElements),
|
getNonDeletedElements(finalElements),
|
||||||
),
|
),
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { load, questionCircle, saveAs } from "../components/icons";
|
import { LoadIcon, questionCircle, saveAs } from "../components/icons";
|
||||||
import { ProjectName } from "../components/ProjectName";
|
import { ProjectName } from "../components/ProjectName";
|
||||||
import { ToolButton } from "../components/ToolButton";
|
import { ToolButton } from "../components/ToolButton";
|
||||||
import "../components/ToolIcon.scss";
|
import "../components/ToolIcon.scss";
|
||||||
@@ -19,6 +19,8 @@ import { ActiveFile } from "../components/ActiveFile";
|
|||||||
import { isImageFileHandle } from "../data/blob";
|
import { isImageFileHandle } from "../data/blob";
|
||||||
import { nativeFileSystemSupported } from "../data/filesystem";
|
import { nativeFileSystemSupported } from "../data/filesystem";
|
||||||
import { Theme } from "../element/types";
|
import { Theme } from "../element/types";
|
||||||
|
import MenuItem from "../components/MenuItem";
|
||||||
|
import { getShortcutFromShortcutName } from "./shortcuts";
|
||||||
|
|
||||||
export const actionChangeProjectName = register({
|
export const actionChangeProjectName = register({
|
||||||
name: "changeProjectName",
|
name: "changeProjectName",
|
||||||
@@ -144,13 +146,15 @@ export const actionSaveToActiveFile = register({
|
|||||||
appState: {
|
appState: {
|
||||||
...appState,
|
...appState,
|
||||||
fileHandle,
|
fileHandle,
|
||||||
toastMessage: fileHandleExists
|
toast: fileHandleExists
|
||||||
? fileHandle?.name
|
? {
|
||||||
? t("toast.fileSavedToFilename").replace(
|
message: fileHandle?.name
|
||||||
"{filename}",
|
? t("toast.fileSavedToFilename").replace(
|
||||||
`"${fileHandle.name}"`,
|
"{filename}",
|
||||||
)
|
`"${fileHandle.name}"`,
|
||||||
: t("toast.fileSaved")
|
)
|
||||||
|
: t("toast.fileSaved"),
|
||||||
|
}
|
||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -175,6 +179,7 @@ export const actionSaveToActiveFile = register({
|
|||||||
|
|
||||||
export const actionSaveFileToDisk = register({
|
export const actionSaveFileToDisk = register({
|
||||||
name: "saveFileToDisk",
|
name: "saveFileToDisk",
|
||||||
|
viewMode: true,
|
||||||
trackEvent: { category: "export" },
|
trackEvent: { category: "export" },
|
||||||
perform: async (elements, appState, value, app) => {
|
perform: async (elements, appState, value, app) => {
|
||||||
try {
|
try {
|
||||||
@@ -242,15 +247,13 @@ export const actionLoadScene = register({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.key === KEYS.O,
|
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.key === KEYS.O,
|
||||||
PanelComponent: ({ updateData, appState }) => (
|
PanelComponent: ({ updateData }) => (
|
||||||
<ToolButton
|
<MenuItem
|
||||||
type="button"
|
label={t("buttons.load")}
|
||||||
icon={load}
|
icon={LoadIcon}
|
||||||
title={t("buttons.load")}
|
|
||||||
aria-label={t("buttons.load")}
|
|
||||||
showAriaLabel={useDevice().isMobile}
|
|
||||||
onClick={updateData}
|
onClick={updateData}
|
||||||
data-testid="load-button"
|
dataTestId="load-button"
|
||||||
|
shortcut={getShortcutFromShortcutName("loadScene")}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
@@ -13,7 +13,7 @@ import {
|
|||||||
maybeBindLinearElement,
|
maybeBindLinearElement,
|
||||||
bindOrUnbindLinearElement,
|
bindOrUnbindLinearElement,
|
||||||
} from "../element/binding";
|
} from "../element/binding";
|
||||||
import { isBindingElement } from "../element/typeChecks";
|
import { isBindingElement, isLinearElement } from "../element/typeChecks";
|
||||||
import { AppState } from "../types";
|
import { AppState } from "../types";
|
||||||
|
|
||||||
export const actionFinalize = register({
|
export const actionFinalize = register({
|
||||||
@@ -181,6 +181,11 @@ export const actionFinalize = register({
|
|||||||
[multiPointElement.id]: true,
|
[multiPointElement.id]: true,
|
||||||
}
|
}
|
||||||
: appState.selectedElementIds,
|
: appState.selectedElementIds,
|
||||||
|
// To select the linear element when user has finished mutipoint editing
|
||||||
|
selectedLinearElement:
|
||||||
|
multiPointElement && isLinearElement(multiPointElement)
|
||||||
|
? new LinearElementEditor(multiPointElement, scene)
|
||||||
|
: appState.selectedLinearElement,
|
||||||
pendingImageElementId: null,
|
pendingImageElementId: null,
|
||||||
},
|
},
|
||||||
commitToHistory: appState.activeTool.type === "freedraw",
|
commitToHistory: appState.activeTool.type === "freedraw",
|
||||||
|
@@ -6,10 +6,15 @@ import { ExcalidrawElement, NonDeleted } from "../element/types";
|
|||||||
import { normalizeAngle, resizeSingleElement } from "../element/resizeElements";
|
import { normalizeAngle, resizeSingleElement } from "../element/resizeElements";
|
||||||
import { AppState } from "../types";
|
import { AppState } from "../types";
|
||||||
import { getTransformHandles } from "../element/transformHandles";
|
import { getTransformHandles } from "../element/transformHandles";
|
||||||
import { isFreeDrawElement, isLinearElement } from "../element/typeChecks";
|
|
||||||
import { updateBoundElements } from "../element/binding";
|
import { updateBoundElements } from "../element/binding";
|
||||||
import { LinearElementEditor } from "../element/linearElementEditor";
|
|
||||||
import { arrayToMap } from "../utils";
|
import { arrayToMap } from "../utils";
|
||||||
|
import {
|
||||||
|
getElementAbsoluteCoords,
|
||||||
|
getElementPointsCoords,
|
||||||
|
} from "../element/bounds";
|
||||||
|
import { isLinearElement } from "../element/typeChecks";
|
||||||
|
import { LinearElementEditor } from "../element/linearElementEditor";
|
||||||
|
import { KEYS } from "../keys";
|
||||||
|
|
||||||
const enableActionFlipHorizontal = (
|
const enableActionFlipHorizontal = (
|
||||||
elements: readonly ExcalidrawElement[],
|
elements: readonly ExcalidrawElement[],
|
||||||
@@ -59,7 +64,8 @@ export const actionFlipVertical = register({
|
|||||||
commitToHistory: true,
|
commitToHistory: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
keyTest: (event) => event.shiftKey && event.code === "KeyV",
|
keyTest: (event) =>
|
||||||
|
event.shiftKey && event.code === "KeyV" && !event[KEYS.CTRL_OR_CMD],
|
||||||
contextItemLabel: "labels.flipVertical",
|
contextItemLabel: "labels.flipVertical",
|
||||||
contextItemPredicate: (elements, appState) =>
|
contextItemPredicate: (elements, appState) =>
|
||||||
enableActionFlipVertical(elements, appState),
|
enableActionFlipVertical(elements, appState),
|
||||||
@@ -118,13 +124,6 @@ const flipElement = (
|
|||||||
const height = element.height;
|
const height = element.height;
|
||||||
const originalAngle = normalizeAngle(element.angle);
|
const originalAngle = normalizeAngle(element.angle);
|
||||||
|
|
||||||
let finalOffsetX = 0;
|
|
||||||
if (isLinearElement(element) || isFreeDrawElement(element)) {
|
|
||||||
finalOffsetX =
|
|
||||||
element.points.reduce((max, point) => Math.max(max, point[0]), 0) * 2 -
|
|
||||||
element.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rotate back to zero, if necessary
|
// Rotate back to zero, if necessary
|
||||||
mutateElement(element, {
|
mutateElement(element, {
|
||||||
angle: normalizeAngle(0),
|
angle: normalizeAngle(0),
|
||||||
@@ -132,7 +131,6 @@ const flipElement = (
|
|||||||
// Flip unrotated by pulling TransformHandle to opposite side
|
// Flip unrotated by pulling TransformHandle to opposite side
|
||||||
const transformHandles = getTransformHandles(element, appState.zoom);
|
const transformHandles = getTransformHandles(element, appState.zoom);
|
||||||
let usingNWHandle = true;
|
let usingNWHandle = true;
|
||||||
let newNCoordsX = 0;
|
|
||||||
let nHandle = transformHandles.nw;
|
let nHandle = transformHandles.nw;
|
||||||
if (!nHandle) {
|
if (!nHandle) {
|
||||||
// Use ne handle instead
|
// Use ne handle instead
|
||||||
@@ -146,30 +144,47 @@ const flipElement = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let finalOffsetX = 0;
|
||||||
|
if (isLinearElement(element) && element.points.length < 3) {
|
||||||
|
finalOffsetX =
|
||||||
|
element.points.reduce((max, point) => Math.max(max, point[0]), 0) * 2 -
|
||||||
|
element.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
let initialPointsCoords;
|
||||||
if (isLinearElement(element)) {
|
if (isLinearElement(element)) {
|
||||||
|
initialPointsCoords = getElementPointsCoords(element, element.points);
|
||||||
|
}
|
||||||
|
const initialElementAbsoluteCoords = getElementAbsoluteCoords(element);
|
||||||
|
|
||||||
|
if (isLinearElement(element) && element.points.length < 3) {
|
||||||
for (let index = 1; index < element.points.length; index++) {
|
for (let index = 1; index < element.points.length; index++) {
|
||||||
LinearElementEditor.movePoints(element, [
|
LinearElementEditor.movePoints(element, [
|
||||||
{ index, point: [-element.points[index][0], element.points[index][1]] },
|
{
|
||||||
|
index,
|
||||||
|
point: [-element.points[index][0], element.points[index][1]],
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
LinearElementEditor.normalizePoints(element);
|
LinearElementEditor.normalizePoints(element);
|
||||||
} else {
|
} else {
|
||||||
// calculate new x-coord for transformation
|
const elWidth = initialPointsCoords
|
||||||
newNCoordsX = usingNWHandle ? element.x + 2 * width : element.x - 2 * width;
|
? initialPointsCoords[2] - initialPointsCoords[0]
|
||||||
|
: initialElementAbsoluteCoords[2] - initialElementAbsoluteCoords[0];
|
||||||
|
|
||||||
|
const startPoint = initialPointsCoords
|
||||||
|
? [initialPointsCoords[0], initialPointsCoords[1]]
|
||||||
|
: [initialElementAbsoluteCoords[0], initialElementAbsoluteCoords[1]];
|
||||||
|
|
||||||
resizeSingleElement(
|
resizeSingleElement(
|
||||||
new Map().set(element.id, element),
|
new Map().set(element.id, element),
|
||||||
true,
|
false,
|
||||||
element,
|
element,
|
||||||
usingNWHandle ? "nw" : "ne",
|
usingNWHandle ? "nw" : "ne",
|
||||||
false,
|
true,
|
||||||
newNCoordsX,
|
usingNWHandle ? startPoint[0] + elWidth : startPoint[0] - elWidth,
|
||||||
nHandle[1],
|
startPoint[1],
|
||||||
);
|
);
|
||||||
// fix the size to account for handle sizes
|
|
||||||
mutateElement(element, {
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rotate by (360 degrees - original angle)
|
// Rotate by (360 degrees - original angle)
|
||||||
@@ -186,9 +201,30 @@ const flipElement = (
|
|||||||
mutateElement(element, {
|
mutateElement(element, {
|
||||||
x: originalX + finalOffsetX,
|
x: originalX + finalOffsetX,
|
||||||
y: originalY,
|
y: originalY,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
});
|
});
|
||||||
|
|
||||||
updateBoundElements(element);
|
updateBoundElements(element);
|
||||||
|
|
||||||
|
if (initialPointsCoords && isLinearElement(element)) {
|
||||||
|
// Adjusting origin because when a beizer curve path exceeds min/max points it offsets the origin.
|
||||||
|
// There's still room for improvement since when the line roughness is > 1
|
||||||
|
// we still have a small offset of the origin when fliipping the element.
|
||||||
|
const finalPointsCoords = getElementPointsCoords(element, element.points);
|
||||||
|
|
||||||
|
const topLeftCoordsDiff = initialPointsCoords[0] - finalPointsCoords[0];
|
||||||
|
const topRightCoordDiff = initialPointsCoords[2] - finalPointsCoords[2];
|
||||||
|
|
||||||
|
const coordsDiff = topLeftCoordsDiff + topRightCoordDiff;
|
||||||
|
|
||||||
|
mutateElement(element, {
|
||||||
|
x: element.x + coordsDiff * 0.5,
|
||||||
|
y: element.y,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const rotateElement = (element: ExcalidrawElement, rotationAngle: number) => {
|
const rotateElement = (element: ExcalidrawElement, rotationAngle: number) => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { CODES, KEYS } from "../keys";
|
import { KEYS } from "../keys";
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { arrayToMap, getShortcutKey } from "../utils";
|
import { arrayToMap, getShortcutKey } from "../utils";
|
||||||
import { register } from "./register";
|
import { register } from "./register";
|
||||||
@@ -132,7 +132,7 @@ export const actionGroup = register({
|
|||||||
contextItemPredicate: (elements, appState) =>
|
contextItemPredicate: (elements, appState) =>
|
||||||
enableActionGroup(elements, appState),
|
enableActionGroup(elements, appState),
|
||||||
keyTest: (event) =>
|
keyTest: (event) =>
|
||||||
!event.shiftKey && event[KEYS.CTRL_OR_CMD] && event.code === CODES.G,
|
!event.shiftKey && event[KEYS.CTRL_OR_CMD] && event.key === KEYS.G,
|
||||||
PanelComponent: ({ elements, appState, updateData }) => (
|
PanelComponent: ({ elements, appState, updateData }) => (
|
||||||
<ToolButton
|
<ToolButton
|
||||||
hidden={!enableActionGroup(elements, appState)}
|
hidden={!enableActionGroup(elements, appState)}
|
||||||
@@ -189,7 +189,9 @@ export const actionUngroup = register({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
keyTest: (event) =>
|
keyTest: (event) =>
|
||||||
event.shiftKey && event[KEYS.CTRL_OR_CMD] && event.code === CODES.G,
|
event.shiftKey &&
|
||||||
|
event[KEYS.CTRL_OR_CMD] &&
|
||||||
|
event.key === KEYS.G.toUpperCase(),
|
||||||
contextItemLabel: "labels.ungroup",
|
contextItemLabel: "labels.ungroup",
|
||||||
contextItemPredicate: (elements, appState) =>
|
contextItemPredicate: (elements, appState) =>
|
||||||
getSelectedGroupIds(appState).length > 0,
|
getSelectedGroupIds(appState).length > 0,
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { Action, ActionResult } from "./types";
|
import { Action, ActionResult } from "./types";
|
||||||
import { undo, redo } from "../components/icons";
|
import { UndoIcon, RedoIcon } from "../components/icons";
|
||||||
import { ToolButton } from "../components/ToolButton";
|
import { ToolButton } from "../components/ToolButton";
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import History, { HistoryEntry } from "../history";
|
import History, { HistoryEntry } from "../history";
|
||||||
@@ -72,7 +72,7 @@ export const createUndoAction: ActionCreator = (history) => ({
|
|||||||
PanelComponent: ({ updateData, data }) => (
|
PanelComponent: ({ updateData, data }) => (
|
||||||
<ToolButton
|
<ToolButton
|
||||||
type="button"
|
type="button"
|
||||||
icon={undo}
|
icon={UndoIcon}
|
||||||
aria-label={t("buttons.undo")}
|
aria-label={t("buttons.undo")}
|
||||||
onClick={updateData}
|
onClick={updateData}
|
||||||
size={data?.size || "medium"}
|
size={data?.size || "medium"}
|
||||||
@@ -94,7 +94,7 @@ export const createRedoAction: ActionCreator = (history) => ({
|
|||||||
PanelComponent: ({ updateData, data }) => (
|
PanelComponent: ({ updateData, data }) => (
|
||||||
<ToolButton
|
<ToolButton
|
||||||
type="button"
|
type="button"
|
||||||
icon={redo}
|
icon={RedoIcon}
|
||||||
aria-label={t("buttons.redo")}
|
aria-label={t("buttons.redo")}
|
||||||
onClick={updateData}
|
onClick={updateData}
|
||||||
size={data?.size || "medium"}
|
size={data?.size || "medium"}
|
||||||
|
49
src/actions/actionLinearEditor.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import { getNonDeletedElements } from "../element";
|
||||||
|
import { LinearElementEditor } from "../element/linearElementEditor";
|
||||||
|
import { isLinearElement } from "../element/typeChecks";
|
||||||
|
import { ExcalidrawLinearElement } from "../element/types";
|
||||||
|
import { getSelectedElements } from "../scene";
|
||||||
|
import { register } from "./register";
|
||||||
|
|
||||||
|
export const actionToggleLinearEditor = register({
|
||||||
|
name: "toggleLinearEditor",
|
||||||
|
trackEvent: {
|
||||||
|
category: "element",
|
||||||
|
},
|
||||||
|
contextItemPredicate: (elements, appState) => {
|
||||||
|
const selectedElements = getSelectedElements(elements, appState);
|
||||||
|
if (selectedElements.length === 1 && isLinearElement(selectedElements[0])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
perform(elements, appState, _, app) {
|
||||||
|
const selectedElement = getSelectedElements(
|
||||||
|
getNonDeletedElements(elements),
|
||||||
|
appState,
|
||||||
|
true,
|
||||||
|
)[0] as ExcalidrawLinearElement;
|
||||||
|
|
||||||
|
const editingLinearElement =
|
||||||
|
appState.editingLinearElement?.elementId === selectedElement.id
|
||||||
|
? null
|
||||||
|
: new LinearElementEditor(selectedElement, app.scene);
|
||||||
|
return {
|
||||||
|
appState: {
|
||||||
|
...appState,
|
||||||
|
editingLinearElement,
|
||||||
|
},
|
||||||
|
commitToHistory: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
contextItemLabel: (elements, appState) => {
|
||||||
|
const selectedElement = getSelectedElements(
|
||||||
|
getNonDeletedElements(elements),
|
||||||
|
appState,
|
||||||
|
true,
|
||||||
|
)[0] as ExcalidrawLinearElement;
|
||||||
|
return appState.editingLinearElement?.elementId === selectedElement.id
|
||||||
|
? "labels.lineEditor.exit"
|
||||||
|
: "labels.lineEditor.edit";
|
||||||
|
},
|
||||||
|
});
|
@@ -1,11 +1,12 @@
|
|||||||
import { menu, palette } from "../components/icons";
|
import { HamburgerMenuIcon, HelpIcon, palette } from "../components/icons";
|
||||||
import { ToolButton } from "../components/ToolButton";
|
import { ToolButton } from "../components/ToolButton";
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { showSelectedShapeActions, getNonDeletedElements } from "../element";
|
import { showSelectedShapeActions, getNonDeletedElements } from "../element";
|
||||||
import { register } from "./register";
|
import { register } from "./register";
|
||||||
import { allowFullScreen, exitFullScreen, isFullScreen } from "../utils";
|
import { allowFullScreen, exitFullScreen, isFullScreen } from "../utils";
|
||||||
import { CODES, KEYS } from "../keys";
|
import { KEYS } from "../keys";
|
||||||
import { HelpIcon } from "../components/HelpIcon";
|
import { HelpButton } from "../components/HelpButton";
|
||||||
|
import MenuItem from "../components/MenuItem";
|
||||||
|
|
||||||
export const actionToggleCanvasMenu = register({
|
export const actionToggleCanvasMenu = register({
|
||||||
name: "toggleCanvasMenu",
|
name: "toggleCanvasMenu",
|
||||||
@@ -20,7 +21,7 @@ export const actionToggleCanvasMenu = register({
|
|||||||
PanelComponent: ({ appState, updateData }) => (
|
PanelComponent: ({ appState, updateData }) => (
|
||||||
<ToolButton
|
<ToolButton
|
||||||
type="button"
|
type="button"
|
||||||
icon={menu}
|
icon={HamburgerMenuIcon}
|
||||||
aria-label={t("buttons.menu")}
|
aria-label={t("buttons.menu")}
|
||||||
onClick={updateData}
|
onClick={updateData}
|
||||||
selected={appState.openMenu === "canvas"}
|
selected={appState.openMenu === "canvas"}
|
||||||
@@ -55,6 +56,7 @@ export const actionToggleEditMenu = register({
|
|||||||
|
|
||||||
export const actionFullScreen = register({
|
export const actionFullScreen = register({
|
||||||
name: "toggleFullScreen",
|
name: "toggleFullScreen",
|
||||||
|
viewMode: true,
|
||||||
trackEvent: { category: "canvas", predicate: (appState) => !isFullScreen() },
|
trackEvent: { category: "canvas", predicate: (appState) => !isFullScreen() },
|
||||||
perform: () => {
|
perform: () => {
|
||||||
if (!isFullScreen()) {
|
if (!isFullScreen()) {
|
||||||
@@ -67,26 +69,36 @@ export const actionFullScreen = register({
|
|||||||
commitToHistory: false,
|
commitToHistory: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
keyTest: (event) => event.code === CODES.F && !event[KEYS.CTRL_OR_CMD],
|
keyTest: (event) => event.key === KEYS.F && !event[KEYS.CTRL_OR_CMD],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const actionShortcuts = register({
|
export const actionShortcuts = register({
|
||||||
name: "toggleShortcuts",
|
name: "toggleShortcuts",
|
||||||
|
viewMode: true,
|
||||||
trackEvent: { category: "menu", action: "toggleHelpDialog" },
|
trackEvent: { category: "menu", action: "toggleHelpDialog" },
|
||||||
perform: (_elements, appState, _, { focusContainer }) => {
|
perform: (_elements, appState, _, { focusContainer }) => {
|
||||||
if (appState.showHelpDialog) {
|
if (appState.openDialog === "help") {
|
||||||
focusContainer();
|
focusContainer();
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
appState: {
|
appState: {
|
||||||
...appState,
|
...appState,
|
||||||
showHelpDialog: !appState.showHelpDialog,
|
openDialog: appState.openDialog === "help" ? null : "help",
|
||||||
},
|
},
|
||||||
commitToHistory: false,
|
commitToHistory: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
PanelComponent: ({ updateData }) => (
|
PanelComponent: ({ updateData, isInHamburgerMenu }) =>
|
||||||
<HelpIcon title={t("helpDialog.title")} onClick={updateData} />
|
isInHamburgerMenu ? (
|
||||||
),
|
<MenuItem
|
||||||
|
label={t("helpDialog.title")}
|
||||||
|
dataTestId="help-menu-item"
|
||||||
|
icon={HelpIcon}
|
||||||
|
onClick={updateData}
|
||||||
|
shortcut="?"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<HelpButton title={t("helpDialog.title")} onClick={updateData} />
|
||||||
|
),
|
||||||
keyTest: (event) => event.key === KEYS.QUESTION_MARK,
|
keyTest: (event) => event.key === KEYS.QUESTION_MARK,
|
||||||
});
|
});
|
||||||
|
@@ -6,6 +6,7 @@ import { register } from "./register";
|
|||||||
|
|
||||||
export const actionGoToCollaborator = register({
|
export const actionGoToCollaborator = register({
|
||||||
name: "goToCollaborator",
|
name: "goToCollaborator",
|
||||||
|
viewMode: true,
|
||||||
trackEvent: { category: "collab" },
|
trackEvent: { category: "collab" },
|
||||||
perform: (_elements, appState, value) => {
|
perform: (_elements, appState, value) => {
|
||||||
const point = value as Collaborator["pointer"];
|
const point = value as Collaborator["pointer"];
|
||||||
|
@@ -2,42 +2,47 @@ import { AppState } from "../../src/types";
|
|||||||
import { ButtonIconSelect } from "../components/ButtonIconSelect";
|
import { ButtonIconSelect } from "../components/ButtonIconSelect";
|
||||||
import { ColorPicker } from "../components/ColorPicker";
|
import { ColorPicker } from "../components/ColorPicker";
|
||||||
import { IconPicker } from "../components/IconPicker";
|
import { IconPicker } from "../components/IconPicker";
|
||||||
|
// TODO barnabasmolnar/editor-redesign
|
||||||
|
// TextAlignTopIcon, TextAlignBottomIcon,TextAlignMiddleIcon,
|
||||||
|
// ArrowHead icons
|
||||||
import {
|
import {
|
||||||
ArrowheadArrowIcon,
|
ArrowheadArrowIcon,
|
||||||
ArrowheadBarIcon,
|
ArrowheadBarIcon,
|
||||||
ArrowheadDotIcon,
|
ArrowheadDotIcon,
|
||||||
ArrowheadTriangleIcon,
|
ArrowheadTriangleIcon,
|
||||||
ArrowheadNoneIcon,
|
ArrowheadNoneIcon,
|
||||||
EdgeRoundIcon,
|
|
||||||
EdgeSharpIcon,
|
|
||||||
FillCrossHatchIcon,
|
|
||||||
FillHachureIcon,
|
|
||||||
FillSolidIcon,
|
|
||||||
FontFamilyCodeIcon,
|
|
||||||
FontFamilyHandDrawnIcon,
|
|
||||||
FontFamilyNormalIcon,
|
|
||||||
FontSizeExtraLargeIcon,
|
|
||||||
FontSizeLargeIcon,
|
|
||||||
FontSizeMediumIcon,
|
|
||||||
FontSizeSmallIcon,
|
|
||||||
SloppinessArchitectIcon,
|
|
||||||
SloppinessArtistIcon,
|
|
||||||
SloppinessCartoonistIcon,
|
|
||||||
StrokeStyleDashedIcon,
|
StrokeStyleDashedIcon,
|
||||||
StrokeStyleDottedIcon,
|
StrokeStyleDottedIcon,
|
||||||
StrokeStyleSolidIcon,
|
|
||||||
StrokeWidthIcon,
|
|
||||||
TextAlignCenterIcon,
|
|
||||||
TextAlignLeftIcon,
|
|
||||||
TextAlignRightIcon,
|
|
||||||
TextAlignTopIcon,
|
TextAlignTopIcon,
|
||||||
TextAlignBottomIcon,
|
TextAlignBottomIcon,
|
||||||
TextAlignMiddleIcon,
|
TextAlignMiddleIcon,
|
||||||
|
FillHachureIcon,
|
||||||
|
FillCrossHatchIcon,
|
||||||
|
FillSolidIcon,
|
||||||
|
SloppinessArchitectIcon,
|
||||||
|
SloppinessArtistIcon,
|
||||||
|
SloppinessCartoonistIcon,
|
||||||
|
StrokeWidthBaseIcon,
|
||||||
|
StrokeWidthBoldIcon,
|
||||||
|
StrokeWidthExtraBoldIcon,
|
||||||
|
FontSizeSmallIcon,
|
||||||
|
FontSizeMediumIcon,
|
||||||
|
FontSizeLargeIcon,
|
||||||
|
FontSizeExtraLargeIcon,
|
||||||
|
EdgeSharpIcon,
|
||||||
|
EdgeRoundIcon,
|
||||||
|
FreedrawIcon,
|
||||||
|
FontFamilyNormalIcon,
|
||||||
|
FontFamilyCodeIcon,
|
||||||
|
TextAlignLeftIcon,
|
||||||
|
TextAlignCenterIcon,
|
||||||
|
TextAlignRightIcon,
|
||||||
} from "../components/icons";
|
} from "../components/icons";
|
||||||
import {
|
import {
|
||||||
DEFAULT_FONT_FAMILY,
|
DEFAULT_FONT_FAMILY,
|
||||||
DEFAULT_FONT_SIZE,
|
DEFAULT_FONT_SIZE,
|
||||||
FONT_FAMILY,
|
FONT_FAMILY,
|
||||||
|
ROUNDNESS,
|
||||||
VERTICAL_ALIGN,
|
VERTICAL_ALIGN,
|
||||||
} from "../constants";
|
} from "../constants";
|
||||||
import {
|
import {
|
||||||
@@ -53,7 +58,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
isBoundToContainer,
|
isBoundToContainer,
|
||||||
isLinearElement,
|
isLinearElement,
|
||||||
isLinearElementType,
|
isUsingAdaptiveRadius,
|
||||||
} from "../element/typeChecks";
|
} from "../element/typeChecks";
|
||||||
import {
|
import {
|
||||||
Arrowhead,
|
Arrowhead,
|
||||||
@@ -68,7 +73,7 @@ import { getLanguage, t } from "../i18n";
|
|||||||
import { KEYS } from "../keys";
|
import { KEYS } from "../keys";
|
||||||
import { randomInteger } from "../random";
|
import { randomInteger } from "../random";
|
||||||
import {
|
import {
|
||||||
canChangeSharpness,
|
canChangeRoundness,
|
||||||
canHaveArrowheads,
|
canHaveArrowheads,
|
||||||
getCommonAttributeOfSelectedElements,
|
getCommonAttributeOfSelectedElements,
|
||||||
getSelectedElements,
|
getSelectedElements,
|
||||||
@@ -307,17 +312,17 @@ export const actionChangeFillStyle = register({
|
|||||||
{
|
{
|
||||||
value: "hachure",
|
value: "hachure",
|
||||||
text: t("labels.hachure"),
|
text: t("labels.hachure"),
|
||||||
icon: <FillHachureIcon theme={appState.theme} />,
|
icon: FillHachureIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "cross-hatch",
|
value: "cross-hatch",
|
||||||
text: t("labels.crossHatch"),
|
text: t("labels.crossHatch"),
|
||||||
icon: <FillCrossHatchIcon theme={appState.theme} />,
|
icon: FillCrossHatchIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "solid",
|
value: "solid",
|
||||||
text: t("labels.solid"),
|
text: t("labels.solid"),
|
||||||
icon: <FillSolidIcon theme={appState.theme} />,
|
icon: FillSolidIcon,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
group="fill"
|
group="fill"
|
||||||
@@ -358,17 +363,17 @@ export const actionChangeStrokeWidth = register({
|
|||||||
{
|
{
|
||||||
value: 1,
|
value: 1,
|
||||||
text: t("labels.thin"),
|
text: t("labels.thin"),
|
||||||
icon: <StrokeWidthIcon theme={appState.theme} strokeWidth={2} />,
|
icon: StrokeWidthBaseIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 2,
|
value: 2,
|
||||||
text: t("labels.bold"),
|
text: t("labels.bold"),
|
||||||
icon: <StrokeWidthIcon theme={appState.theme} strokeWidth={6} />,
|
icon: StrokeWidthBoldIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 4,
|
value: 4,
|
||||||
text: t("labels.extraBold"),
|
text: t("labels.extraBold"),
|
||||||
icon: <StrokeWidthIcon theme={appState.theme} strokeWidth={10} />,
|
icon: StrokeWidthExtraBoldIcon,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
value={getFormValue(
|
value={getFormValue(
|
||||||
@@ -407,17 +412,17 @@ export const actionChangeSloppiness = register({
|
|||||||
{
|
{
|
||||||
value: 0,
|
value: 0,
|
||||||
text: t("labels.architect"),
|
text: t("labels.architect"),
|
||||||
icon: <SloppinessArchitectIcon theme={appState.theme} />,
|
icon: SloppinessArchitectIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 1,
|
value: 1,
|
||||||
text: t("labels.artist"),
|
text: t("labels.artist"),
|
||||||
icon: <SloppinessArtistIcon theme={appState.theme} />,
|
icon: SloppinessArtistIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 2,
|
value: 2,
|
||||||
text: t("labels.cartoonist"),
|
text: t("labels.cartoonist"),
|
||||||
icon: <SloppinessCartoonistIcon theme={appState.theme} />,
|
icon: SloppinessCartoonistIcon,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
value={getFormValue(
|
value={getFormValue(
|
||||||
@@ -455,17 +460,17 @@ export const actionChangeStrokeStyle = register({
|
|||||||
{
|
{
|
||||||
value: "solid",
|
value: "solid",
|
||||||
text: t("labels.strokeStyle_solid"),
|
text: t("labels.strokeStyle_solid"),
|
||||||
icon: <StrokeStyleSolidIcon theme={appState.theme} />,
|
icon: StrokeWidthBaseIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "dashed",
|
value: "dashed",
|
||||||
text: t("labels.strokeStyle_dashed"),
|
text: t("labels.strokeStyle_dashed"),
|
||||||
icon: <StrokeStyleDashedIcon theme={appState.theme} />,
|
icon: StrokeStyleDashedIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "dotted",
|
value: "dotted",
|
||||||
text: t("labels.strokeStyle_dotted"),
|
text: t("labels.strokeStyle_dotted"),
|
||||||
icon: <StrokeStyleDottedIcon theme={appState.theme} />,
|
icon: StrokeStyleDottedIcon,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
value={getFormValue(
|
value={getFormValue(
|
||||||
@@ -535,25 +540,25 @@ export const actionChangeFontSize = register({
|
|||||||
{
|
{
|
||||||
value: 16,
|
value: 16,
|
||||||
text: t("labels.small"),
|
text: t("labels.small"),
|
||||||
icon: <FontSizeSmallIcon theme={appState.theme} />,
|
icon: FontSizeSmallIcon,
|
||||||
testId: "fontSize-small",
|
testId: "fontSize-small",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 20,
|
value: 20,
|
||||||
text: t("labels.medium"),
|
text: t("labels.medium"),
|
||||||
icon: <FontSizeMediumIcon theme={appState.theme} />,
|
icon: FontSizeMediumIcon,
|
||||||
testId: "fontSize-medium",
|
testId: "fontSize-medium",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 28,
|
value: 28,
|
||||||
text: t("labels.large"),
|
text: t("labels.large"),
|
||||||
icon: <FontSizeLargeIcon theme={appState.theme} />,
|
icon: FontSizeLargeIcon,
|
||||||
testId: "fontSize-large",
|
testId: "fontSize-large",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 36,
|
value: 36,
|
||||||
text: t("labels.veryLarge"),
|
text: t("labels.veryLarge"),
|
||||||
icon: <FontSizeExtraLargeIcon theme={appState.theme} />,
|
icon: FontSizeExtraLargeIcon,
|
||||||
testId: "fontSize-veryLarge",
|
testId: "fontSize-veryLarge",
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
@@ -658,17 +663,17 @@ export const actionChangeFontFamily = register({
|
|||||||
{
|
{
|
||||||
value: FONT_FAMILY.Virgil,
|
value: FONT_FAMILY.Virgil,
|
||||||
text: t("labels.handDrawn"),
|
text: t("labels.handDrawn"),
|
||||||
icon: <FontFamilyHandDrawnIcon theme={appState.theme} />,
|
icon: FreedrawIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: FONT_FAMILY.Helvetica,
|
value: FONT_FAMILY.Helvetica,
|
||||||
text: t("labels.normal"),
|
text: t("labels.normal"),
|
||||||
icon: <FontFamilyNormalIcon theme={appState.theme} />,
|
icon: FontFamilyNormalIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: FONT_FAMILY.Cascadia,
|
value: FONT_FAMILY.Cascadia,
|
||||||
text: t("labels.code"),
|
text: t("labels.code"),
|
||||||
icon: <FontFamilyCodeIcon theme={appState.theme} />,
|
icon: FontFamilyCodeIcon,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -739,17 +744,17 @@ export const actionChangeTextAlign = register({
|
|||||||
{
|
{
|
||||||
value: "left",
|
value: "left",
|
||||||
text: t("labels.left"),
|
text: t("labels.left"),
|
||||||
icon: <TextAlignLeftIcon theme={appState.theme} />,
|
icon: TextAlignLeftIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "center",
|
value: "center",
|
||||||
text: t("labels.center"),
|
text: t("labels.center"),
|
||||||
icon: <TextAlignCenterIcon theme={appState.theme} />,
|
icon: TextAlignCenterIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "right",
|
value: "right",
|
||||||
text: t("labels.right"),
|
text: t("labels.right"),
|
||||||
icon: <TextAlignRightIcon theme={appState.theme} />,
|
icon: TextAlignRightIcon,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
value={getFormValue(
|
value={getFormValue(
|
||||||
@@ -812,16 +817,19 @@ export const actionChangeVerticalAlign = register({
|
|||||||
value: VERTICAL_ALIGN.TOP,
|
value: VERTICAL_ALIGN.TOP,
|
||||||
text: t("labels.alignTop"),
|
text: t("labels.alignTop"),
|
||||||
icon: <TextAlignTopIcon theme={appState.theme} />,
|
icon: <TextAlignTopIcon theme={appState.theme} />,
|
||||||
|
testId: "align-top",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: VERTICAL_ALIGN.MIDDLE,
|
value: VERTICAL_ALIGN.MIDDLE,
|
||||||
text: t("labels.centerVertically"),
|
text: t("labels.centerVertically"),
|
||||||
icon: <TextAlignMiddleIcon theme={appState.theme} />,
|
icon: <TextAlignMiddleIcon theme={appState.theme} />,
|
||||||
|
testId: "align-middle",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: VERTICAL_ALIGN.BOTTOM,
|
value: VERTICAL_ALIGN.BOTTOM,
|
||||||
text: t("labels.alignBottom"),
|
text: t("labels.alignBottom"),
|
||||||
icon: <TextAlignBottomIcon theme={appState.theme} />,
|
icon: <TextAlignBottomIcon theme={appState.theme} />,
|
||||||
|
testId: "align-bottom",
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
value={getFormValue(elements, appState, (element) => {
|
value={getFormValue(elements, appState, (element) => {
|
||||||
@@ -841,69 +849,71 @@ export const actionChangeVerticalAlign = register({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const actionChangeSharpness = register({
|
export const actionChangeRoundness = register({
|
||||||
name: "changeSharpness",
|
name: "changeRoundness",
|
||||||
trackEvent: false,
|
trackEvent: false,
|
||||||
perform: (elements, appState, value) => {
|
perform: (elements, appState, value) => {
|
||||||
const targetElements = getTargetElements(
|
|
||||||
getNonDeletedElements(elements),
|
|
||||||
appState,
|
|
||||||
);
|
|
||||||
const shouldUpdateForNonLinearElements = targetElements.length
|
|
||||||
? targetElements.every((el) => !isLinearElement(el))
|
|
||||||
: !isLinearElementType(appState.activeTool.type);
|
|
||||||
const shouldUpdateForLinearElements = targetElements.length
|
|
||||||
? targetElements.every(isLinearElement)
|
|
||||||
: isLinearElementType(appState.activeTool.type);
|
|
||||||
return {
|
return {
|
||||||
elements: changeProperty(elements, appState, (el) =>
|
elements: changeProperty(elements, appState, (el) =>
|
||||||
newElementWith(el, {
|
newElementWith(el, {
|
||||||
strokeSharpness: value,
|
roundness:
|
||||||
|
value === "round"
|
||||||
|
? {
|
||||||
|
type: isUsingAdaptiveRadius(el.type)
|
||||||
|
? ROUNDNESS.ADAPTIVE_RADIUS
|
||||||
|
: ROUNDNESS.PROPORTIONAL_RADIUS,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
appState: {
|
appState: {
|
||||||
...appState,
|
...appState,
|
||||||
currentItemStrokeSharpness: shouldUpdateForNonLinearElements
|
currentItemRoundness: value,
|
||||||
? value
|
|
||||||
: appState.currentItemStrokeSharpness,
|
|
||||||
currentItemLinearStrokeSharpness: shouldUpdateForLinearElements
|
|
||||||
? value
|
|
||||||
: appState.currentItemLinearStrokeSharpness,
|
|
||||||
},
|
},
|
||||||
commitToHistory: true,
|
commitToHistory: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
PanelComponent: ({ elements, appState, updateData }) => (
|
PanelComponent: ({ elements, appState, updateData }) => {
|
||||||
<fieldset>
|
const targetElements = getTargetElements(
|
||||||
<legend>{t("labels.edges")}</legend>
|
getNonDeletedElements(elements),
|
||||||
<ButtonIconSelect
|
appState,
|
||||||
group="edges"
|
);
|
||||||
options={[
|
|
||||||
{
|
const hasLegacyRoundness = targetElements.some(
|
||||||
value: "sharp",
|
(el) => el.roundness?.type === ROUNDNESS.LEGACY,
|
||||||
text: t("labels.sharp"),
|
);
|
||||||
icon: <EdgeSharpIcon theme={appState.theme} />,
|
|
||||||
},
|
return (
|
||||||
{
|
<fieldset>
|
||||||
value: "round",
|
<legend>{t("labels.edges")}</legend>
|
||||||
text: t("labels.round"),
|
<ButtonIconSelect
|
||||||
icon: <EdgeRoundIcon theme={appState.theme} />,
|
group="edges"
|
||||||
},
|
options={[
|
||||||
]}
|
{
|
||||||
value={getFormValue(
|
value: "sharp",
|
||||||
elements,
|
text: t("labels.sharp"),
|
||||||
appState,
|
icon: EdgeSharpIcon,
|
||||||
(element) => element.strokeSharpness,
|
},
|
||||||
(canChangeSharpness(appState.activeTool.type) &&
|
{
|
||||||
(isLinearElementType(appState.activeTool.type)
|
value: "round",
|
||||||
? appState.currentItemLinearStrokeSharpness
|
text: t("labels.round"),
|
||||||
: appState.currentItemStrokeSharpness)) ||
|
icon: EdgeRoundIcon,
|
||||||
null,
|
},
|
||||||
)}
|
]}
|
||||||
onChange={(value) => updateData(value)}
|
value={getFormValue(
|
||||||
/>
|
elements,
|
||||||
</fieldset>
|
appState,
|
||||||
),
|
(element) =>
|
||||||
|
hasLegacyRoundness ? null : element.roundness ? "round" : "sharp",
|
||||||
|
(canChangeRoundness(appState.activeTool.type) &&
|
||||||
|
appState.currentItemRoundness) ||
|
||||||
|
null,
|
||||||
|
)}
|
||||||
|
onChange={(value) => updateData(value)}
|
||||||
|
/>
|
||||||
|
</fieldset>
|
||||||
|
);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const actionChangeArrowhead = register({
|
export const actionChangeArrowhead = register({
|
||||||
@@ -949,42 +959,38 @@ export const actionChangeArrowhead = register({
|
|||||||
return (
|
return (
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{t("labels.arrowheads")}</legend>
|
<legend>{t("labels.arrowheads")}</legend>
|
||||||
<div className="iconSelectList">
|
<div className="iconSelectList buttonList">
|
||||||
<IconPicker
|
<IconPicker
|
||||||
label="arrowhead_start"
|
label="arrowhead_start"
|
||||||
options={[
|
options={[
|
||||||
{
|
{
|
||||||
value: null,
|
value: null,
|
||||||
text: t("labels.arrowhead_none"),
|
text: t("labels.arrowhead_none"),
|
||||||
icon: <ArrowheadNoneIcon theme={appState.theme} />,
|
icon: ArrowheadNoneIcon,
|
||||||
keyBinding: "q",
|
keyBinding: "q",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "arrow",
|
value: "arrow",
|
||||||
text: t("labels.arrowhead_arrow"),
|
text: t("labels.arrowhead_arrow"),
|
||||||
icon: (
|
icon: <ArrowheadArrowIcon flip={!isRTL} />,
|
||||||
<ArrowheadArrowIcon theme={appState.theme} flip={!isRTL} />
|
|
||||||
),
|
|
||||||
keyBinding: "w",
|
keyBinding: "w",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "bar",
|
value: "bar",
|
||||||
text: t("labels.arrowhead_bar"),
|
text: t("labels.arrowhead_bar"),
|
||||||
icon: <ArrowheadBarIcon theme={appState.theme} flip={!isRTL} />,
|
icon: <ArrowheadBarIcon flip={!isRTL} />,
|
||||||
keyBinding: "e",
|
keyBinding: "e",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "dot",
|
value: "dot",
|
||||||
text: t("labels.arrowhead_dot"),
|
text: t("labels.arrowhead_dot"),
|
||||||
icon: <ArrowheadDotIcon theme={appState.theme} flip={!isRTL} />,
|
icon: <ArrowheadDotIcon flip={!isRTL} />,
|
||||||
keyBinding: "r",
|
keyBinding: "r",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "triangle",
|
value: "triangle",
|
||||||
text: t("labels.arrowhead_triangle"),
|
text: t("labels.arrowhead_triangle"),
|
||||||
icon: (
|
icon: <ArrowheadTriangleIcon flip={!isRTL} />,
|
||||||
<ArrowheadTriangleIcon theme={appState.theme} flip={!isRTL} />
|
|
||||||
),
|
|
||||||
keyBinding: "t",
|
keyBinding: "t",
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
@@ -1007,34 +1013,30 @@ export const actionChangeArrowhead = register({
|
|||||||
value: null,
|
value: null,
|
||||||
text: t("labels.arrowhead_none"),
|
text: t("labels.arrowhead_none"),
|
||||||
keyBinding: "q",
|
keyBinding: "q",
|
||||||
icon: <ArrowheadNoneIcon theme={appState.theme} />,
|
icon: ArrowheadNoneIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "arrow",
|
value: "arrow",
|
||||||
text: t("labels.arrowhead_arrow"),
|
text: t("labels.arrowhead_arrow"),
|
||||||
keyBinding: "w",
|
keyBinding: "w",
|
||||||
icon: (
|
icon: <ArrowheadArrowIcon flip={isRTL} />,
|
||||||
<ArrowheadArrowIcon theme={appState.theme} flip={isRTL} />
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "bar",
|
value: "bar",
|
||||||
text: t("labels.arrowhead_bar"),
|
text: t("labels.arrowhead_bar"),
|
||||||
keyBinding: "e",
|
keyBinding: "e",
|
||||||
icon: <ArrowheadBarIcon theme={appState.theme} flip={isRTL} />,
|
icon: <ArrowheadBarIcon flip={isRTL} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "dot",
|
value: "dot",
|
||||||
text: t("labels.arrowhead_dot"),
|
text: t("labels.arrowhead_dot"),
|
||||||
keyBinding: "r",
|
keyBinding: "r",
|
||||||
icon: <ArrowheadDotIcon theme={appState.theme} flip={isRTL} />,
|
icon: <ArrowheadDotIcon flip={isRTL} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "triangle",
|
value: "triangle",
|
||||||
text: t("labels.arrowhead_triangle"),
|
text: t("labels.arrowhead_triangle"),
|
||||||
icon: (
|
icon: <ArrowheadTriangleIcon flip={isRTL} />,
|
||||||
<ArrowheadTriangleIcon theme={appState.theme} flip={isRTL} />
|
|
||||||
),
|
|
||||||
keyBinding: "t",
|
keyBinding: "t",
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
@@ -2,29 +2,43 @@ import { KEYS } from "../keys";
|
|||||||
import { register } from "./register";
|
import { register } from "./register";
|
||||||
import { selectGroupsForSelectedElements } from "../groups";
|
import { selectGroupsForSelectedElements } from "../groups";
|
||||||
import { getNonDeletedElements, isTextElement } from "../element";
|
import { getNonDeletedElements, isTextElement } from "../element";
|
||||||
|
import { ExcalidrawElement } from "../element/types";
|
||||||
|
import { isLinearElement } from "../element/typeChecks";
|
||||||
|
import { LinearElementEditor } from "../element/linearElementEditor";
|
||||||
|
|
||||||
export const actionSelectAll = register({
|
export const actionSelectAll = register({
|
||||||
name: "selectAll",
|
name: "selectAll",
|
||||||
trackEvent: { category: "canvas" },
|
trackEvent: { category: "canvas" },
|
||||||
perform: (elements, appState) => {
|
perform: (elements, appState, value, app) => {
|
||||||
if (appState.editingLinearElement) {
|
if (appState.editingLinearElement) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const selectedElementIds = elements.reduce(
|
||||||
|
(map: Record<ExcalidrawElement["id"], true>, element) => {
|
||||||
|
if (
|
||||||
|
!element.isDeleted &&
|
||||||
|
!(isTextElement(element) && element.containerId) &&
|
||||||
|
!element.locked
|
||||||
|
) {
|
||||||
|
map[element.id] = true;
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
appState: selectGroupsForSelectedElements(
|
appState: selectGroupsForSelectedElements(
|
||||||
{
|
{
|
||||||
...appState,
|
...appState,
|
||||||
|
selectedLinearElement:
|
||||||
|
// single linear element selected
|
||||||
|
Object.keys(selectedElementIds).length === 1 &&
|
||||||
|
isLinearElement(elements[0])
|
||||||
|
? new LinearElementEditor(elements[0], app.scene)
|
||||||
|
: null,
|
||||||
editingGroupId: null,
|
editingGroupId: null,
|
||||||
selectedElementIds: elements.reduce((map, element) => {
|
selectedElementIds,
|
||||||
if (
|
|
||||||
!element.isDeleted &&
|
|
||||||
!(isTextElement(element) && element.containerId) &&
|
|
||||||
element.locked === false
|
|
||||||
) {
|
|
||||||
map[element.id] = true;
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}, {} as any),
|
|
||||||
},
|
},
|
||||||
getNonDeletedElements(elements),
|
getNonDeletedElements(elements),
|
||||||
),
|
),
|
||||||
|
@@ -13,7 +13,11 @@ import {
|
|||||||
DEFAULT_TEXT_ALIGN,
|
DEFAULT_TEXT_ALIGN,
|
||||||
} from "../constants";
|
} from "../constants";
|
||||||
import { getBoundTextElement } from "../element/textElement";
|
import { getBoundTextElement } from "../element/textElement";
|
||||||
import { hasBoundTextElement } from "../element/typeChecks";
|
import {
|
||||||
|
hasBoundTextElement,
|
||||||
|
canApplyRoundnessTypeToElement,
|
||||||
|
getDefaultRoundnessTypeForElement,
|
||||||
|
} from "../element/typeChecks";
|
||||||
import { getSelectedElements } from "../scene";
|
import { getSelectedElements } from "../scene";
|
||||||
|
|
||||||
// `copiedStyles` is exported only for tests.
|
// `copiedStyles` is exported only for tests.
|
||||||
@@ -36,7 +40,7 @@ export const actionCopyStyles = register({
|
|||||||
return {
|
return {
|
||||||
appState: {
|
appState: {
|
||||||
...appState,
|
...appState,
|
||||||
toastMessage: t("toast.copyStyles"),
|
toast: { message: t("toast.copyStyles") },
|
||||||
},
|
},
|
||||||
commitToHistory: false,
|
commitToHistory: false,
|
||||||
};
|
};
|
||||||
@@ -77,6 +81,14 @@ export const actionPasteStyles = register({
|
|||||||
fillStyle: elementStylesToCopyFrom?.fillStyle,
|
fillStyle: elementStylesToCopyFrom?.fillStyle,
|
||||||
opacity: elementStylesToCopyFrom?.opacity,
|
opacity: elementStylesToCopyFrom?.opacity,
|
||||||
roughness: elementStylesToCopyFrom?.roughness,
|
roughness: elementStylesToCopyFrom?.roughness,
|
||||||
|
roundness: elementStylesToCopyFrom.roundness
|
||||||
|
? canApplyRoundnessTypeToElement(
|
||||||
|
elementStylesToCopyFrom.roundness.type,
|
||||||
|
element,
|
||||||
|
)
|
||||||
|
? elementStylesToCopyFrom.roundness
|
||||||
|
: getDefaultRoundnessTypeForElement(element)
|
||||||
|
: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isTextElement(newElement)) {
|
if (isTextElement(newElement)) {
|
||||||
|
@@ -5,6 +5,7 @@ import { AppState } from "../types";
|
|||||||
|
|
||||||
export const actionToggleGridMode = register({
|
export const actionToggleGridMode = register({
|
||||||
name: "gridMode",
|
name: "gridMode",
|
||||||
|
viewMode: true,
|
||||||
trackEvent: {
|
trackEvent: {
|
||||||
category: "canvas",
|
category: "canvas",
|
||||||
predicate: (appState) => !appState.gridSize,
|
predicate: (appState) => !appState.gridSize,
|
||||||
@@ -19,6 +20,9 @@ export const actionToggleGridMode = register({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
checked: (appState: AppState) => appState.gridSize !== null,
|
checked: (appState: AppState) => appState.gridSize !== null,
|
||||||
|
contextItemPredicate: (element, appState, props) => {
|
||||||
|
return typeof props.gridModeEnabled === "undefined";
|
||||||
|
},
|
||||||
contextItemLabel: "labels.showGrid",
|
contextItemLabel: "labels.showGrid",
|
||||||
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.code === CODES.QUOTE,
|
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.code === CODES.QUOTE,
|
||||||
});
|
});
|
||||||
|
@@ -17,16 +17,19 @@ export const actionToggleLock = register({
|
|||||||
|
|
||||||
const operation = getOperation(selectedElements);
|
const operation = getOperation(selectedElements);
|
||||||
const selectedElementsMap = arrayToMap(selectedElements);
|
const selectedElementsMap = arrayToMap(selectedElements);
|
||||||
|
const lock = operation === "lock";
|
||||||
return {
|
return {
|
||||||
elements: elements.map((element) => {
|
elements: elements.map((element) => {
|
||||||
if (!selectedElementsMap.has(element.id)) {
|
if (!selectedElementsMap.has(element.id)) {
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
return newElementWith(element, { locked: operation === "lock" });
|
return newElementWith(element, { locked: lock });
|
||||||
}),
|
}),
|
||||||
appState,
|
appState: {
|
||||||
|
...appState,
|
||||||
|
selectedLinearElement: lock ? null : appState.selectedLinearElement,
|
||||||
|
},
|
||||||
commitToHistory: true,
|
commitToHistory: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -38,15 +41,9 @@ export const actionToggleLock = register({
|
|||||||
: "labels.elementLock.lock";
|
: "labels.elementLock.lock";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected.length > 1) {
|
return getOperation(selected) === "lock"
|
||||||
return getOperation(selected) === "lock"
|
? "labels.elementLock.lockAll"
|
||||||
? "labels.elementLock.lockAll"
|
: "labels.elementLock.unlockAll";
|
||||||
: "labels.elementLock.unlockAll";
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error(
|
|
||||||
"Unexpected zero elements to lock/unlock. This should never happen.",
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
keyTest: (event, appState, elements) => {
|
keyTest: (event, appState, elements) => {
|
||||||
return (
|
return (
|
||||||
|
@@ -3,6 +3,7 @@ import { CODES, KEYS } from "../keys";
|
|||||||
|
|
||||||
export const actionToggleStats = register({
|
export const actionToggleStats = register({
|
||||||
name: "stats",
|
name: "stats",
|
||||||
|
viewMode: true,
|
||||||
trackEvent: { category: "menu" },
|
trackEvent: { category: "menu" },
|
||||||
perform(elements, appState) {
|
perform(elements, appState) {
|
||||||
return {
|
return {
|
||||||
|
@@ -3,6 +3,7 @@ import { register } from "./register";
|
|||||||
|
|
||||||
export const actionToggleViewMode = register({
|
export const actionToggleViewMode = register({
|
||||||
name: "viewMode",
|
name: "viewMode",
|
||||||
|
viewMode: true,
|
||||||
trackEvent: {
|
trackEvent: {
|
||||||
category: "canvas",
|
category: "canvas",
|
||||||
predicate: (appState) => !appState.viewModeEnabled,
|
predicate: (appState) => !appState.viewModeEnabled,
|
||||||
@@ -17,6 +18,9 @@ export const actionToggleViewMode = register({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
checked: (appState) => appState.viewModeEnabled,
|
checked: (appState) => appState.viewModeEnabled,
|
||||||
|
contextItemPredicate: (elements, appState, appProps) => {
|
||||||
|
return typeof appProps.viewModeEnabled === "undefined";
|
||||||
|
},
|
||||||
contextItemLabel: "labels.viewMode",
|
contextItemLabel: "labels.viewMode",
|
||||||
keyTest: (event) =>
|
keyTest: (event) =>
|
||||||
!event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === CODES.R,
|
!event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === CODES.R,
|
||||||
|
@@ -3,6 +3,7 @@ import { register } from "./register";
|
|||||||
|
|
||||||
export const actionToggleZenMode = register({
|
export const actionToggleZenMode = register({
|
||||||
name: "zenMode",
|
name: "zenMode",
|
||||||
|
viewMode: true,
|
||||||
trackEvent: {
|
trackEvent: {
|
||||||
category: "canvas",
|
category: "canvas",
|
||||||
predicate: (appState) => !appState.zenModeEnabled,
|
predicate: (appState) => !appState.zenModeEnabled,
|
||||||
@@ -17,6 +18,9 @@ export const actionToggleZenMode = register({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
checked: (appState) => appState.zenModeEnabled,
|
checked: (appState) => appState.zenModeEnabled,
|
||||||
|
contextItemPredicate: (elements, appState, appProps) => {
|
||||||
|
return typeof appProps.zenModeEnabled === "undefined";
|
||||||
|
},
|
||||||
contextItemLabel: "buttons.zenMode",
|
contextItemLabel: "buttons.zenMode",
|
||||||
keyTest: (event) =>
|
keyTest: (event) =>
|
||||||
!event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === CODES.Z,
|
!event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === CODES.Z,
|
||||||
|
@@ -10,10 +10,10 @@ import { t } from "../i18n";
|
|||||||
import { getShortcutKey } from "../utils";
|
import { getShortcutKey } from "../utils";
|
||||||
import { register } from "./register";
|
import { register } from "./register";
|
||||||
import {
|
import {
|
||||||
SendBackwardIcon,
|
|
||||||
BringToFrontIcon,
|
|
||||||
SendToBackIcon,
|
|
||||||
BringForwardIcon,
|
BringForwardIcon,
|
||||||
|
BringToFrontIcon,
|
||||||
|
SendBackwardIcon,
|
||||||
|
SendToBackIcon,
|
||||||
} from "../components/icons";
|
} from "../components/icons";
|
||||||
|
|
||||||
export const actionSendBackward = register({
|
export const actionSendBackward = register({
|
||||||
@@ -39,7 +39,7 @@ export const actionSendBackward = register({
|
|||||||
onClick={() => updateData(null)}
|
onClick={() => updateData(null)}
|
||||||
title={`${t("labels.sendBackward")} — ${getShortcutKey("CtrlOrCmd+[")}`}
|
title={`${t("labels.sendBackward")} — ${getShortcutKey("CtrlOrCmd+[")}`}
|
||||||
>
|
>
|
||||||
<SendBackwardIcon theme={appState.theme} />
|
{SendBackwardIcon}
|
||||||
</button>
|
</button>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
@@ -67,7 +67,7 @@ export const actionBringForward = register({
|
|||||||
onClick={() => updateData(null)}
|
onClick={() => updateData(null)}
|
||||||
title={`${t("labels.bringForward")} — ${getShortcutKey("CtrlOrCmd+]")}`}
|
title={`${t("labels.bringForward")} — ${getShortcutKey("CtrlOrCmd+]")}`}
|
||||||
>
|
>
|
||||||
<BringForwardIcon theme={appState.theme} />
|
{BringForwardIcon}
|
||||||
</button>
|
</button>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
@@ -102,7 +102,7 @@ export const actionSendToBack = register({
|
|||||||
: getShortcutKey("CtrlOrCmd+Shift+[")
|
: getShortcutKey("CtrlOrCmd+Shift+[")
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<SendToBackIcon theme={appState.theme} />
|
{SendToBackIcon}
|
||||||
</button>
|
</button>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
@@ -138,7 +138,7 @@ export const actionBringToFront = register({
|
|||||||
: getShortcutKey("CtrlOrCmd+Shift+]")
|
: getShortcutKey("CtrlOrCmd+Shift+]")
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<BringToFrontIcon theme={appState.theme} />
|
{BringToFrontIcon}
|
||||||
</button>
|
</button>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
@@ -85,3 +85,4 @@ export { actionToggleStats } from "./actionToggleStats";
|
|||||||
export { actionUnbindText, actionBindText } from "./actionBoundText";
|
export { actionUnbindText, actionBindText } from "./actionBoundText";
|
||||||
export { actionLink } from "../element/Hyperlink";
|
export { actionLink } from "../element/Hyperlink";
|
||||||
export { actionToggleLock } from "./actionToggleLock";
|
export { actionToggleLock } from "./actionToggleLock";
|
||||||
|
export { actionToggleLinearEditor } from "./actionLinearEditor";
|
||||||
|
@@ -9,7 +9,6 @@ import {
|
|||||||
} from "./types";
|
} from "./types";
|
||||||
import { ExcalidrawElement } from "../element/types";
|
import { ExcalidrawElement } from "../element/types";
|
||||||
import { AppClassProperties, AppState } from "../types";
|
import { AppClassProperties, AppState } from "../types";
|
||||||
import { MODES } from "../constants";
|
|
||||||
import { trackEvent } from "../analytics";
|
import { trackEvent } from "../analytics";
|
||||||
|
|
||||||
const trackAction = (
|
const trackAction = (
|
||||||
@@ -103,11 +102,8 @@ export class ActionManager {
|
|||||||
|
|
||||||
const action = data[0];
|
const action = data[0];
|
||||||
|
|
||||||
const { viewModeEnabled } = this.getAppState();
|
if (this.getAppState().viewModeEnabled && action.viewMode !== true) {
|
||||||
if (viewModeEnabled) {
|
return false;
|
||||||
if (!Object.values(MODES).includes(data[0].name)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const elements = this.getElementsIncludingDeleted();
|
const elements = this.getElementsIncludingDeleted();
|
||||||
@@ -135,7 +131,11 @@ export class ActionManager {
|
|||||||
/**
|
/**
|
||||||
* @param data additional data sent to the PanelComponent
|
* @param data additional data sent to the PanelComponent
|
||||||
*/
|
*/
|
||||||
renderAction = (name: ActionName, data?: PanelComponentProps["data"]) => {
|
renderAction = (
|
||||||
|
name: ActionName,
|
||||||
|
data?: PanelComponentProps["data"],
|
||||||
|
isInHamburgerMenu = false,
|
||||||
|
) => {
|
||||||
const canvasActions = this.app.props.UIOptions.canvasActions;
|
const canvasActions = this.app.props.UIOptions.canvasActions;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -147,6 +147,7 @@ export class ActionManager {
|
|||||||
) {
|
) {
|
||||||
const action = this.actions[name];
|
const action = this.actions[name];
|
||||||
const PanelComponent = action.PanelComponent!;
|
const PanelComponent = action.PanelComponent!;
|
||||||
|
PanelComponent.displayName = "PanelComponent";
|
||||||
const elements = this.getElementsIncludingDeleted();
|
const elements = this.getElementsIncludingDeleted();
|
||||||
const appState = this.getAppState();
|
const appState = this.getAppState();
|
||||||
const updateData = (formState?: any) => {
|
const updateData = (formState?: any) => {
|
||||||
@@ -169,6 +170,7 @@ export class ActionManager {
|
|||||||
updateData={updateData}
|
updateData={updateData}
|
||||||
appProps={this.app.props}
|
appProps={this.app.props}
|
||||||
data={data}
|
data={data}
|
||||||
|
isInHamburgerMenu={isInHamburgerMenu}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -3,43 +3,52 @@ import { isDarwin } from "../keys";
|
|||||||
import { getShortcutKey } from "../utils";
|
import { getShortcutKey } from "../utils";
|
||||||
import { ActionName } from "./types";
|
import { ActionName } from "./types";
|
||||||
|
|
||||||
export type ShortcutName = SubtypeOf<
|
export type ShortcutName =
|
||||||
ActionName,
|
| SubtypeOf<
|
||||||
| "cut"
|
ActionName,
|
||||||
| "copy"
|
| "toggleTheme"
|
||||||
| "paste"
|
| "loadScene"
|
||||||
| "copyStyles"
|
| "cut"
|
||||||
| "pasteStyles"
|
| "copy"
|
||||||
| "selectAll"
|
| "paste"
|
||||||
| "deleteSelectedElements"
|
| "copyStyles"
|
||||||
| "duplicateSelection"
|
| "pasteStyles"
|
||||||
| "sendBackward"
|
| "selectAll"
|
||||||
| "bringForward"
|
| "deleteSelectedElements"
|
||||||
| "sendToBack"
|
| "duplicateSelection"
|
||||||
| "bringToFront"
|
| "sendBackward"
|
||||||
| "copyAsPng"
|
| "bringForward"
|
||||||
| "copyAsSvg"
|
| "sendToBack"
|
||||||
| "group"
|
| "bringToFront"
|
||||||
| "ungroup"
|
| "copyAsPng"
|
||||||
| "gridMode"
|
| "copyAsSvg"
|
||||||
| "zenMode"
|
| "group"
|
||||||
| "stats"
|
| "ungroup"
|
||||||
| "addToLibrary"
|
| "gridMode"
|
||||||
| "viewMode"
|
| "zenMode"
|
||||||
| "flipHorizontal"
|
| "stats"
|
||||||
| "flipVertical"
|
| "addToLibrary"
|
||||||
| "hyperlink"
|
| "viewMode"
|
||||||
| "toggleLock"
|
| "flipHorizontal"
|
||||||
>;
|
| "flipVertical"
|
||||||
|
| "hyperlink"
|
||||||
|
| "toggleLock"
|
||||||
|
>
|
||||||
|
| "saveScene"
|
||||||
|
| "imageExport";
|
||||||
|
|
||||||
const shortcutMap: Record<ShortcutName, string[]> = {
|
const shortcutMap: Record<ShortcutName, string[]> = {
|
||||||
|
toggleTheme: [getShortcutKey("Shift+Alt+D")],
|
||||||
|
saveScene: [getShortcutKey("CtrlOrCmd+S")],
|
||||||
|
loadScene: [getShortcutKey("CtrlOrCmd+O")],
|
||||||
|
imageExport: [getShortcutKey("CtrlOrCmd+Shift+E")],
|
||||||
cut: [getShortcutKey("CtrlOrCmd+X")],
|
cut: [getShortcutKey("CtrlOrCmd+X")],
|
||||||
copy: [getShortcutKey("CtrlOrCmd+C")],
|
copy: [getShortcutKey("CtrlOrCmd+C")],
|
||||||
paste: [getShortcutKey("CtrlOrCmd+V")],
|
paste: [getShortcutKey("CtrlOrCmd+V")],
|
||||||
copyStyles: [getShortcutKey("CtrlOrCmd+Alt+C")],
|
copyStyles: [getShortcutKey("CtrlOrCmd+Alt+C")],
|
||||||
pasteStyles: [getShortcutKey("CtrlOrCmd+Alt+V")],
|
pasteStyles: [getShortcutKey("CtrlOrCmd+Alt+V")],
|
||||||
selectAll: [getShortcutKey("CtrlOrCmd+A")],
|
selectAll: [getShortcutKey("CtrlOrCmd+A")],
|
||||||
deleteSelectedElements: [getShortcutKey("Del")],
|
deleteSelectedElements: [getShortcutKey("Delete")],
|
||||||
duplicateSelection: [
|
duplicateSelection: [
|
||||||
getShortcutKey("CtrlOrCmd+D"),
|
getShortcutKey("CtrlOrCmd+D"),
|
||||||
getShortcutKey(`Alt+${t("helpDialog.drag")}`),
|
getShortcutKey(`Alt+${t("helpDialog.drag")}`),
|
||||||
|
@@ -91,7 +91,7 @@ export type ActionName =
|
|||||||
| "ungroup"
|
| "ungroup"
|
||||||
| "goToCollaborator"
|
| "goToCollaborator"
|
||||||
| "addToLibrary"
|
| "addToLibrary"
|
||||||
| "changeSharpness"
|
| "changeRoundness"
|
||||||
| "alignTop"
|
| "alignTop"
|
||||||
| "alignBottom"
|
| "alignBottom"
|
||||||
| "alignLeft"
|
| "alignLeft"
|
||||||
@@ -111,7 +111,8 @@ export type ActionName =
|
|||||||
| "hyperlink"
|
| "hyperlink"
|
||||||
| "eraser"
|
| "eraser"
|
||||||
| "bindText"
|
| "bindText"
|
||||||
| "toggleLock";
|
| "toggleLock"
|
||||||
|
| "toggleLinearEditor";
|
||||||
|
|
||||||
export type PanelComponentProps = {
|
export type PanelComponentProps = {
|
||||||
elements: readonly ExcalidrawElement[];
|
elements: readonly ExcalidrawElement[];
|
||||||
@@ -123,7 +124,9 @@ export type PanelComponentProps = {
|
|||||||
|
|
||||||
export interface Action {
|
export interface Action {
|
||||||
name: ActionName;
|
name: ActionName;
|
||||||
PanelComponent?: React.FC<PanelComponentProps>;
|
PanelComponent?: React.FC<
|
||||||
|
PanelComponentProps & { isInHamburgerMenu: boolean }
|
||||||
|
>;
|
||||||
perform: ActionFn;
|
perform: ActionFn;
|
||||||
keyPriority?: number;
|
keyPriority?: number;
|
||||||
keyTest?: (
|
keyTest?: (
|
||||||
@@ -140,6 +143,8 @@ export interface Action {
|
|||||||
contextItemPredicate?: (
|
contextItemPredicate?: (
|
||||||
elements: readonly ExcalidrawElement[],
|
elements: readonly ExcalidrawElement[],
|
||||||
appState: AppState,
|
appState: AppState,
|
||||||
|
appProps: ExcalidrawProps,
|
||||||
|
app: AppClassProperties,
|
||||||
) => boolean;
|
) => boolean;
|
||||||
checked?: (appState: Readonly<AppState>) => boolean;
|
checked?: (appState: Readonly<AppState>) => boolean;
|
||||||
trackEvent:
|
trackEvent:
|
||||||
@@ -161,4 +166,7 @@ export interface Action {
|
|||||||
value: any,
|
value: any,
|
||||||
) => boolean;
|
) => boolean;
|
||||||
};
|
};
|
||||||
|
/** if set to `true`, allow action to be performed in viewMode.
|
||||||
|
* Defaults to `false` */
|
||||||
|
viewMode?: boolean;
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,7 @@ export const getDefaultAppState = (): Omit<
|
|||||||
"offsetTop" | "offsetLeft" | "width" | "height"
|
"offsetTop" | "offsetLeft" | "width" | "height"
|
||||||
> => {
|
> => {
|
||||||
return {
|
return {
|
||||||
|
showWelcomeScreen: false,
|
||||||
theme: THEME.LIGHT,
|
theme: THEME.LIGHT,
|
||||||
collaborators: new Map(),
|
collaborators: new Map(),
|
||||||
currentChartType: "bar",
|
currentChartType: "bar",
|
||||||
@@ -27,12 +28,11 @@ export const getDefaultAppState = (): Omit<
|
|||||||
currentItemFillStyle: "hachure",
|
currentItemFillStyle: "hachure",
|
||||||
currentItemFontFamily: DEFAULT_FONT_FAMILY,
|
currentItemFontFamily: DEFAULT_FONT_FAMILY,
|
||||||
currentItemFontSize: DEFAULT_FONT_SIZE,
|
currentItemFontSize: DEFAULT_FONT_SIZE,
|
||||||
currentItemLinearStrokeSharpness: "round",
|
|
||||||
currentItemOpacity: 100,
|
currentItemOpacity: 100,
|
||||||
currentItemRoughness: 1,
|
currentItemRoughness: 1,
|
||||||
currentItemStartArrowhead: null,
|
currentItemStartArrowhead: null,
|
||||||
currentItemStrokeColor: oc.black,
|
currentItemStrokeColor: oc.black,
|
||||||
currentItemStrokeSharpness: "sharp",
|
currentItemRoundness: "round",
|
||||||
currentItemStrokeStyle: "solid",
|
currentItemStrokeStyle: "solid",
|
||||||
currentItemStrokeWidth: 1,
|
currentItemStrokeWidth: 1,
|
||||||
currentItemTextAlign: DEFAULT_TEXT_ALIGN,
|
currentItemTextAlign: DEFAULT_TEXT_ALIGN,
|
||||||
@@ -57,16 +57,18 @@ export const getDefaultAppState = (): Omit<
|
|||||||
fileHandle: null,
|
fileHandle: null,
|
||||||
gridSize: null,
|
gridSize: null,
|
||||||
isBindingEnabled: true,
|
isBindingEnabled: true,
|
||||||
isLibraryOpen: false,
|
isSidebarDocked: false,
|
||||||
isLibraryMenuDocked: false,
|
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isResizing: false,
|
isResizing: false,
|
||||||
isRotating: false,
|
isRotating: false,
|
||||||
lastPointerDownWith: "mouse",
|
lastPointerDownWith: "mouse",
|
||||||
multiElement: null,
|
multiElement: null,
|
||||||
name: `${t("labels.untitled")}-${getDateTime()}`,
|
name: `${t("labels.untitled")}-${getDateTime()}`,
|
||||||
|
contextMenu: null,
|
||||||
openMenu: null,
|
openMenu: null,
|
||||||
openPopup: null,
|
openPopup: null,
|
||||||
|
openSidebar: null,
|
||||||
|
openDialog: null,
|
||||||
pasteDialog: { shown: false, data: null },
|
pasteDialog: { shown: false, data: null },
|
||||||
previousSelectedElementIds: {},
|
previousSelectedElementIds: {},
|
||||||
resizingElement: null,
|
resizingElement: null,
|
||||||
@@ -77,11 +79,10 @@ export const getDefaultAppState = (): Omit<
|
|||||||
selectedGroupIds: {},
|
selectedGroupIds: {},
|
||||||
selectionElement: null,
|
selectionElement: null,
|
||||||
shouldCacheIgnoreZoom: false,
|
shouldCacheIgnoreZoom: false,
|
||||||
showHelpDialog: false,
|
|
||||||
showStats: false,
|
showStats: false,
|
||||||
startBoundElement: null,
|
startBoundElement: null,
|
||||||
suggestedBindings: [],
|
suggestedBindings: [],
|
||||||
toastMessage: null,
|
toast: null,
|
||||||
viewBackgroundColor: oc.white,
|
viewBackgroundColor: oc.white,
|
||||||
zenModeEnabled: false,
|
zenModeEnabled: false,
|
||||||
zoom: {
|
zoom: {
|
||||||
@@ -90,6 +91,7 @@ export const getDefaultAppState = (): Omit<
|
|||||||
viewModeEnabled: false,
|
viewModeEnabled: false,
|
||||||
pendingImageElementId: null,
|
pendingImageElementId: null,
|
||||||
showHyperlinkPopup: false,
|
showHyperlinkPopup: false,
|
||||||
|
selectedLinearElement: null,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -109,6 +111,7 @@ const APP_STATE_STORAGE_CONF = (<
|
|||||||
T extends Record<keyof AppState, Values>,
|
T extends Record<keyof AppState, Values>,
|
||||||
>(config: { [K in keyof T]: K extends keyof AppState ? T[K] : never }) =>
|
>(config: { [K in keyof T]: K extends keyof AppState ? T[K] : never }) =>
|
||||||
config)({
|
config)({
|
||||||
|
showWelcomeScreen: { browser: true, export: false, server: false },
|
||||||
theme: { browser: true, export: false, server: false },
|
theme: { browser: true, export: false, server: false },
|
||||||
collaborators: { browser: false, export: false, server: false },
|
collaborators: { browser: false, export: false, server: false },
|
||||||
currentChartType: { browser: true, export: false, server: false },
|
currentChartType: { browser: true, export: false, server: false },
|
||||||
@@ -117,7 +120,7 @@ const APP_STATE_STORAGE_CONF = (<
|
|||||||
currentItemFillStyle: { browser: true, export: false, server: false },
|
currentItemFillStyle: { browser: true, export: false, server: false },
|
||||||
currentItemFontFamily: { browser: true, export: false, server: false },
|
currentItemFontFamily: { browser: true, export: false, server: false },
|
||||||
currentItemFontSize: { browser: true, export: false, server: false },
|
currentItemFontSize: { browser: true, export: false, server: false },
|
||||||
currentItemLinearStrokeSharpness: {
|
currentItemRoundness: {
|
||||||
browser: true,
|
browser: true,
|
||||||
export: false,
|
export: false,
|
||||||
server: false,
|
server: false,
|
||||||
@@ -126,7 +129,6 @@ const APP_STATE_STORAGE_CONF = (<
|
|||||||
currentItemRoughness: { browser: true, export: false, server: false },
|
currentItemRoughness: { browser: true, export: false, server: false },
|
||||||
currentItemStartArrowhead: { browser: true, export: false, server: false },
|
currentItemStartArrowhead: { browser: true, export: false, server: false },
|
||||||
currentItemStrokeColor: { browser: true, export: false, server: false },
|
currentItemStrokeColor: { browser: true, export: false, server: false },
|
||||||
currentItemStrokeSharpness: { browser: true, export: false, server: false },
|
|
||||||
currentItemStrokeStyle: { browser: true, export: false, server: false },
|
currentItemStrokeStyle: { browser: true, export: false, server: false },
|
||||||
currentItemStrokeWidth: { browser: true, export: false, server: false },
|
currentItemStrokeWidth: { browser: true, export: false, server: false },
|
||||||
currentItemTextAlign: { browser: true, export: false, server: false },
|
currentItemTextAlign: { browser: true, export: false, server: false },
|
||||||
@@ -147,8 +149,7 @@ const APP_STATE_STORAGE_CONF = (<
|
|||||||
gridSize: { browser: true, export: true, server: true },
|
gridSize: { browser: true, export: true, server: true },
|
||||||
height: { browser: false, export: false, server: false },
|
height: { browser: false, export: false, server: false },
|
||||||
isBindingEnabled: { browser: false, export: false, server: false },
|
isBindingEnabled: { browser: false, export: false, server: false },
|
||||||
isLibraryOpen: { browser: true, export: false, server: false },
|
isSidebarDocked: { browser: true, export: false, server: false },
|
||||||
isLibraryMenuDocked: { browser: true, export: false, server: false },
|
|
||||||
isLoading: { browser: false, export: false, server: false },
|
isLoading: { browser: false, export: false, server: false },
|
||||||
isResizing: { browser: false, export: false, server: false },
|
isResizing: { browser: false, export: false, server: false },
|
||||||
isRotating: { browser: false, export: false, server: false },
|
isRotating: { browser: false, export: false, server: false },
|
||||||
@@ -157,8 +158,11 @@ const APP_STATE_STORAGE_CONF = (<
|
|||||||
name: { browser: true, export: false, server: false },
|
name: { browser: true, export: false, server: false },
|
||||||
offsetLeft: { browser: false, export: false, server: false },
|
offsetLeft: { browser: false, export: false, server: false },
|
||||||
offsetTop: { browser: false, export: false, server: false },
|
offsetTop: { browser: false, export: false, server: false },
|
||||||
|
contextMenu: { browser: false, export: false, server: false },
|
||||||
openMenu: { browser: true, export: false, server: false },
|
openMenu: { browser: true, export: false, server: false },
|
||||||
openPopup: { browser: false, export: false, server: false },
|
openPopup: { browser: false, export: false, server: false },
|
||||||
|
openSidebar: { browser: true, export: false, server: false },
|
||||||
|
openDialog: { browser: false, export: false, server: false },
|
||||||
pasteDialog: { browser: false, export: false, server: false },
|
pasteDialog: { browser: false, export: false, server: false },
|
||||||
previousSelectedElementIds: { browser: true, export: false, server: false },
|
previousSelectedElementIds: { browser: true, export: false, server: false },
|
||||||
resizingElement: { browser: false, export: false, server: false },
|
resizingElement: { browser: false, export: false, server: false },
|
||||||
@@ -169,11 +173,10 @@ const APP_STATE_STORAGE_CONF = (<
|
|||||||
selectedGroupIds: { browser: true, export: false, server: false },
|
selectedGroupIds: { browser: true, export: false, server: false },
|
||||||
selectionElement: { browser: false, export: false, server: false },
|
selectionElement: { browser: false, export: false, server: false },
|
||||||
shouldCacheIgnoreZoom: { browser: true, export: false, server: false },
|
shouldCacheIgnoreZoom: { browser: true, export: false, server: false },
|
||||||
showHelpDialog: { browser: false, export: false, server: false },
|
|
||||||
showStats: { browser: true, export: false, server: false },
|
showStats: { browser: true, export: false, server: false },
|
||||||
startBoundElement: { browser: false, export: false, server: false },
|
startBoundElement: { browser: false, export: false, server: false },
|
||||||
suggestedBindings: { browser: false, export: false, server: false },
|
suggestedBindings: { browser: false, export: false, server: false },
|
||||||
toastMessage: { browser: false, export: false, server: false },
|
toast: { browser: false, export: false, server: false },
|
||||||
viewBackgroundColor: { browser: true, export: true, server: true },
|
viewBackgroundColor: { browser: true, export: true, server: true },
|
||||||
width: { browser: false, export: false, server: false },
|
width: { browser: false, export: false, server: false },
|
||||||
zenModeEnabled: { browser: true, export: false, server: false },
|
zenModeEnabled: { browser: true, export: false, server: false },
|
||||||
@@ -181,6 +184,7 @@ const APP_STATE_STORAGE_CONF = (<
|
|||||||
viewModeEnabled: { browser: false, export: false, server: false },
|
viewModeEnabled: { browser: false, export: false, server: false },
|
||||||
pendingImageElementId: { browser: false, export: false, server: false },
|
pendingImageElementId: { browser: false, export: false, server: false },
|
||||||
showHyperlinkPopup: { browser: false, export: false, server: false },
|
showHyperlinkPopup: { browser: false, export: false, server: false },
|
||||||
|
selectedLinearElement: { browser: true, export: false, server: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
const _clearAppStateForStorage = <
|
const _clearAppStateForStorage = <
|
||||||
|
@@ -172,7 +172,7 @@ const commonProps = {
|
|||||||
opacity: 100,
|
opacity: 100,
|
||||||
roughness: 1,
|
roughness: 1,
|
||||||
strokeColor: colors.elementStroke[0],
|
strokeColor: colors.elementStroke[0],
|
||||||
strokeSharpness: "sharp",
|
roundness: null,
|
||||||
strokeStyle: "solid",
|
strokeStyle: "solid",
|
||||||
strokeWidth: 1,
|
strokeWidth: 1,
|
||||||
verticalAlign: VERTICAL_ALIGN.MIDDLE,
|
verticalAlign: VERTICAL_ALIGN.MIDDLE,
|
||||||
@@ -322,7 +322,7 @@ const chartBaseElements = (
|
|||||||
text: spreadsheet.title,
|
text: spreadsheet.title,
|
||||||
x: x + chartWidth / 2,
|
x: x + chartWidth / 2,
|
||||||
y: y - BAR_HEIGHT - BAR_GAP * 2 - DEFAULT_FONT_SIZE,
|
y: y - BAR_HEIGHT - BAR_GAP * 2 - DEFAULT_FONT_SIZE,
|
||||||
strokeSharpness: "sharp",
|
roundness: null,
|
||||||
strokeStyle: "solid",
|
strokeStyle: "solid",
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
})
|
})
|
||||||
|
@@ -11,27 +11,18 @@ export const getClientColors = (clientId: string, appState: AppState) => {
|
|||||||
// Naive way of getting an integer out of the clientId
|
// Naive way of getting an integer out of the clientId
|
||||||
const sum = clientId.split("").reduce((a, str) => a + str.charCodeAt(0), 0);
|
const sum = clientId.split("").reduce((a, str) => a + str.charCodeAt(0), 0);
|
||||||
|
|
||||||
// Skip transparent background.
|
// Skip transparent & gray colors
|
||||||
const backgrounds = colors.elementBackground.slice(1);
|
const backgrounds = colors.elementBackground.slice(3);
|
||||||
const strokes = colors.elementStroke.slice(1);
|
const strokes = colors.elementStroke.slice(3);
|
||||||
return {
|
return {
|
||||||
background: backgrounds[sum % backgrounds.length],
|
background: backgrounds[sum % backgrounds.length],
|
||||||
stroke: strokes[sum % strokes.length],
|
stroke: strokes[sum % strokes.length],
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getClientInitials = (username?: string | null) => {
|
export const getClientInitials = (userName?: string | null) => {
|
||||||
if (!username) {
|
if (!userName) {
|
||||||
return "?";
|
return "?";
|
||||||
}
|
}
|
||||||
const names = username.trim().split(" ");
|
return userName.trim()[0].toUpperCase();
|
||||||
|
|
||||||
if (names.length < 2) {
|
|
||||||
return names[0].substring(0, 2).toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
const firstName = names[0];
|
|
||||||
const lastName = names[names.length - 1];
|
|
||||||
|
|
||||||
return (firstName[0] + lastName[0]).toUpperCase();
|
|
||||||
};
|
};
|
||||||
|
27
src/clipboard.test.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { parseClipboard } from "./clipboard";
|
||||||
|
|
||||||
|
describe("Test parseClipboard", () => {
|
||||||
|
it("should parse valid json correctly", async () => {
|
||||||
|
let text = "123";
|
||||||
|
|
||||||
|
let clipboardData = await parseClipboard({
|
||||||
|
//@ts-ignore
|
||||||
|
clipboardData: {
|
||||||
|
getData: () => text,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(clipboardData.text).toBe(text);
|
||||||
|
|
||||||
|
text = "[123]";
|
||||||
|
|
||||||
|
clipboardData = await parseClipboard({
|
||||||
|
//@ts-ignore
|
||||||
|
clipboardData: {
|
||||||
|
getData: () => text,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(clipboardData.text).toBe(text);
|
||||||
|
});
|
||||||
|
});
|
@@ -109,16 +109,16 @@ const parsePotentialSpreadsheet = (
|
|||||||
* Retrieves content from system clipboard (either from ClipboardEvent or
|
* Retrieves content from system clipboard (either from ClipboardEvent or
|
||||||
* via async clipboard API if supported)
|
* via async clipboard API if supported)
|
||||||
*/
|
*/
|
||||||
const getSystemClipboard = async (
|
export const getSystemClipboard = async (
|
||||||
event: ClipboardEvent | null,
|
event: ClipboardEvent | null,
|
||||||
): Promise<string> => {
|
): Promise<string> => {
|
||||||
try {
|
try {
|
||||||
const text = event
|
const text = event
|
||||||
? event.clipboardData?.getData("text/plain").trim()
|
? event.clipboardData?.getData("text/plain")
|
||||||
: probablySupportsClipboardReadText &&
|
: probablySupportsClipboardReadText &&
|
||||||
(await navigator.clipboard.readText());
|
(await navigator.clipboard.readText());
|
||||||
|
|
||||||
return text || "";
|
return (text || "").trim();
|
||||||
} catch {
|
} catch {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -129,19 +129,25 @@ const getSystemClipboard = async (
|
|||||||
*/
|
*/
|
||||||
export const parseClipboard = async (
|
export const parseClipboard = async (
|
||||||
event: ClipboardEvent | null,
|
event: ClipboardEvent | null,
|
||||||
|
isPlainPaste = false,
|
||||||
): Promise<ClipboardData> => {
|
): Promise<ClipboardData> => {
|
||||||
const systemClipboard = await getSystemClipboard(event);
|
const systemClipboard = await getSystemClipboard(event);
|
||||||
|
|
||||||
// if system clipboard empty, couldn't be resolved, or contains previously
|
// if system clipboard empty, couldn't be resolved, or contains previously
|
||||||
// copied excalidraw scene as SVG, fall back to previously copied excalidraw
|
// copied excalidraw scene as SVG, fall back to previously copied excalidraw
|
||||||
// elements
|
// elements
|
||||||
if (!systemClipboard || systemClipboard.includes(SVG_EXPORT_TAG)) {
|
if (
|
||||||
|
!systemClipboard ||
|
||||||
|
(!isPlainPaste && systemClipboard.includes(SVG_EXPORT_TAG))
|
||||||
|
) {
|
||||||
return getAppClipboard();
|
return getAppClipboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if system clipboard contains spreadsheet, use it even though it's
|
// if system clipboard contains spreadsheet, use it even though it's
|
||||||
// technically possible it's staler than in-app clipboard
|
// technically possible it's staler than in-app clipboard
|
||||||
const spreadsheetResult = parsePotentialSpreadsheet(systemClipboard);
|
const spreadsheetResult =
|
||||||
|
!isPlainPaste && parsePotentialSpreadsheet(systemClipboard);
|
||||||
|
|
||||||
if (spreadsheetResult) {
|
if (spreadsheetResult) {
|
||||||
return spreadsheetResult;
|
return spreadsheetResult;
|
||||||
}
|
}
|
||||||
@@ -154,17 +160,23 @@ export const parseClipboard = async (
|
|||||||
return {
|
return {
|
||||||
elements: systemClipboardData.elements,
|
elements: systemClipboardData.elements,
|
||||||
files: systemClipboardData.files,
|
files: systemClipboardData.files,
|
||||||
|
text: isPlainPaste
|
||||||
|
? JSON.stringify(systemClipboardData.elements, null, 2)
|
||||||
|
: undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return appClipboardData;
|
} catch (e) {}
|
||||||
} catch {
|
// system clipboard doesn't contain excalidraw elements → return plaintext
|
||||||
// system clipboard doesn't contain excalidraw elements → return plaintext
|
// unless we set a flag to prefer in-app clipboard because browser didn't
|
||||||
// unless we set a flag to prefer in-app clipboard because browser didn't
|
// support storing to system clipboard on copy
|
||||||
// support storing to system clipboard on copy
|
return PREFER_APP_CLIPBOARD && appClipboardData.elements
|
||||||
return PREFER_APP_CLIPBOARD && appClipboardData.elements
|
? {
|
||||||
? appClipboardData
|
...appClipboardData,
|
||||||
: { text: systemClipboard };
|
text: isPlainPaste
|
||||||
}
|
? JSON.stringify(appClipboardData.elements, null, 2)
|
||||||
|
: undefined,
|
||||||
|
}
|
||||||
|
: { text: systemClipboard };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const copyBlobToClipboardAsPng = async (blob: Blob | Promise<Blob>) => {
|
export const copyBlobToClipboardAsPng = async (blob: Blob | Promise<Blob>) => {
|
||||||
|
92
src/components/Actions.scss
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
.zoom-actions,
|
||||||
|
.undo-redo-buttons {
|
||||||
|
background-color: var(--island-bg-color);
|
||||||
|
border-radius: var(--border-radius-lg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.zoom-button,
|
||||||
|
.undo-redo-buttons button {
|
||||||
|
border: 1px solid var(--default-border-color) !important;
|
||||||
|
border-radius: 0 !important;
|
||||||
|
background-color: transparent !important;
|
||||||
|
font-size: 0.875rem !important;
|
||||||
|
width: var(--lg-button-size);
|
||||||
|
height: var(--lg-button-size);
|
||||||
|
svg {
|
||||||
|
width: var(--lg-icon-size) !important;
|
||||||
|
height: var(--lg-icon-size) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ToolIcon__icon {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.reset-zoom-button {
|
||||||
|
border-left: 0 !important;
|
||||||
|
border-right: 0 !important;
|
||||||
|
padding: 0 0.625rem !important;
|
||||||
|
width: 3.75rem !important;
|
||||||
|
justify-content: center;
|
||||||
|
color: var(--text-primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.zoom-out-button {
|
||||||
|
border-top-left-radius: var(--border-radius-lg) !important;
|
||||||
|
border-bottom-left-radius: var(--border-radius-lg) !important;
|
||||||
|
|
||||||
|
:root[dir="rtl"] & {
|
||||||
|
transform: scaleX(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ToolIcon__icon {
|
||||||
|
border-top-right-radius: 0 !important;
|
||||||
|
border-bottom-right-radius: 0 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.zoom-in-button {
|
||||||
|
border-top-right-radius: var(--border-radius-lg) !important;
|
||||||
|
border-bottom-right-radius: var(--border-radius-lg) !important;
|
||||||
|
|
||||||
|
:root[dir="rtl"] & {
|
||||||
|
transform: scaleX(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ToolIcon__icon {
|
||||||
|
border-top-left-radius: 0 !important;
|
||||||
|
border-bottom-left-radius: 0 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.undo-redo-buttons {
|
||||||
|
.undo-button-container button {
|
||||||
|
border-top-left-radius: var(--border-radius-lg) !important;
|
||||||
|
border-bottom-left-radius: var(--border-radius-lg) !important;
|
||||||
|
border-right: 0 !important;
|
||||||
|
|
||||||
|
:root[dir="rtl"] & {
|
||||||
|
transform: scaleX(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ToolIcon__icon {
|
||||||
|
border-top-right-radius: 0 !important;
|
||||||
|
border-bottom-right-radius: 0 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.redo-button-container button {
|
||||||
|
border-top-right-radius: var(--border-radius-lg) !important;
|
||||||
|
border-bottom-right-radius: var(--border-radius-lg) !important;
|
||||||
|
|
||||||
|
:root[dir="rtl"] & {
|
||||||
|
transform: scaleX(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ToolIcon__icon {
|
||||||
|
border-top-left-radius: 0 !important;
|
||||||
|
border-bottom-left-radius: 0 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -5,7 +5,7 @@ import { ExcalidrawElement, PointerType } from "../element/types";
|
|||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { useDevice } from "../components/App";
|
import { useDevice } from "../components/App";
|
||||||
import {
|
import {
|
||||||
canChangeSharpness,
|
canChangeRoundness,
|
||||||
canHaveArrowheads,
|
canHaveArrowheads,
|
||||||
getTargetElements,
|
getTargetElements,
|
||||||
hasBackground,
|
hasBackground,
|
||||||
@@ -25,18 +25,21 @@ import Stack from "./Stack";
|
|||||||
import { ToolButton } from "./ToolButton";
|
import { ToolButton } from "./ToolButton";
|
||||||
import { hasStrokeColor } from "../scene/comparisons";
|
import { hasStrokeColor } from "../scene/comparisons";
|
||||||
import { trackEvent } from "../analytics";
|
import { trackEvent } from "../analytics";
|
||||||
import { hasBoundTextElement, isBoundToContainer } from "../element/typeChecks";
|
import { hasBoundTextElement } from "../element/typeChecks";
|
||||||
|
import clsx from "clsx";
|
||||||
|
import { actionToggleZenMode } from "../actions";
|
||||||
|
import "./Actions.scss";
|
||||||
|
import { Tooltip } from "./Tooltip";
|
||||||
|
import { shouldAllowVerticalAlign } from "../element/textElement";
|
||||||
|
|
||||||
export const SelectedShapeActions = ({
|
export const SelectedShapeActions = ({
|
||||||
appState,
|
appState,
|
||||||
elements,
|
elements,
|
||||||
renderAction,
|
renderAction,
|
||||||
activeTool,
|
|
||||||
}: {
|
}: {
|
||||||
appState: AppState;
|
appState: AppState;
|
||||||
elements: readonly ExcalidrawElement[];
|
elements: readonly ExcalidrawElement[];
|
||||||
renderAction: ActionManager["renderAction"];
|
renderAction: ActionManager["renderAction"];
|
||||||
activeTool: AppState["activeTool"]["type"];
|
|
||||||
}) => {
|
}) => {
|
||||||
const targetElements = getTargetElements(
|
const targetElements = getTargetElements(
|
||||||
getNonDeletedElements(elements),
|
getNonDeletedElements(elements),
|
||||||
@@ -56,13 +59,13 @@ export const SelectedShapeActions = ({
|
|||||||
const isRTL = document.documentElement.getAttribute("dir") === "rtl";
|
const isRTL = document.documentElement.getAttribute("dir") === "rtl";
|
||||||
|
|
||||||
const showFillIcons =
|
const showFillIcons =
|
||||||
hasBackground(activeTool) ||
|
hasBackground(appState.activeTool.type) ||
|
||||||
targetElements.some(
|
targetElements.some(
|
||||||
(element) =>
|
(element) =>
|
||||||
hasBackground(element.type) && !isTransparent(element.backgroundColor),
|
hasBackground(element.type) && !isTransparent(element.backgroundColor),
|
||||||
);
|
);
|
||||||
const showChangeBackgroundIcons =
|
const showChangeBackgroundIcons =
|
||||||
hasBackground(activeTool) ||
|
hasBackground(appState.activeTool.type) ||
|
||||||
targetElements.some((element) => hasBackground(element.type));
|
targetElements.some((element) => hasBackground(element.type));
|
||||||
|
|
||||||
const showLinkIcon =
|
const showLinkIcon =
|
||||||
@@ -79,23 +82,27 @@ export const SelectedShapeActions = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="panelColumn">
|
<div className="panelColumn">
|
||||||
{((hasStrokeColor(activeTool) &&
|
<div>
|
||||||
activeTool !== "image" &&
|
{((hasStrokeColor(appState.activeTool.type) &&
|
||||||
commonSelectedType !== "image") ||
|
appState.activeTool.type !== "image" &&
|
||||||
targetElements.some((element) => hasStrokeColor(element.type))) &&
|
commonSelectedType !== "image") ||
|
||||||
renderAction("changeStrokeColor")}
|
targetElements.some((element) => hasStrokeColor(element.type))) &&
|
||||||
{showChangeBackgroundIcons && renderAction("changeBackgroundColor")}
|
renderAction("changeStrokeColor")}
|
||||||
|
</div>
|
||||||
|
{showChangeBackgroundIcons && (
|
||||||
|
<div>{renderAction("changeBackgroundColor")}</div>
|
||||||
|
)}
|
||||||
{showFillIcons && renderAction("changeFillStyle")}
|
{showFillIcons && renderAction("changeFillStyle")}
|
||||||
|
|
||||||
{(hasStrokeWidth(activeTool) ||
|
{(hasStrokeWidth(appState.activeTool.type) ||
|
||||||
targetElements.some((element) => hasStrokeWidth(element.type))) &&
|
targetElements.some((element) => hasStrokeWidth(element.type))) &&
|
||||||
renderAction("changeStrokeWidth")}
|
renderAction("changeStrokeWidth")}
|
||||||
|
|
||||||
{(activeTool === "freedraw" ||
|
{(appState.activeTool.type === "freedraw" ||
|
||||||
targetElements.some((element) => element.type === "freedraw")) &&
|
targetElements.some((element) => element.type === "freedraw")) &&
|
||||||
renderAction("changeStrokeShape")}
|
renderAction("changeStrokeShape")}
|
||||||
|
|
||||||
{(hasStrokeStyle(activeTool) ||
|
{(hasStrokeStyle(appState.activeTool.type) ||
|
||||||
targetElements.some((element) => hasStrokeStyle(element.type))) && (
|
targetElements.some((element) => hasStrokeStyle(element.type))) && (
|
||||||
<>
|
<>
|
||||||
{renderAction("changeStrokeStyle")}
|
{renderAction("changeStrokeStyle")}
|
||||||
@@ -103,12 +110,12 @@ export const SelectedShapeActions = ({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{(canChangeSharpness(activeTool) ||
|
{(canChangeRoundness(appState.activeTool.type) ||
|
||||||
targetElements.some((element) => canChangeSharpness(element.type))) && (
|
targetElements.some((element) => canChangeRoundness(element.type))) && (
|
||||||
<>{renderAction("changeSharpness")}</>
|
<>{renderAction("changeRoundness")}</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{(hasText(activeTool) ||
|
{(hasText(appState.activeTool.type) ||
|
||||||
targetElements.some((element) => hasText(element.type))) && (
|
targetElements.some((element) => hasText(element.type))) && (
|
||||||
<>
|
<>
|
||||||
{renderAction("changeFontSize")}
|
{renderAction("changeFontSize")}
|
||||||
@@ -119,11 +126,9 @@ export const SelectedShapeActions = ({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{targetElements.some(
|
{shouldAllowVerticalAlign(targetElements) &&
|
||||||
(element) =>
|
renderAction("changeVerticalAlign")}
|
||||||
hasBoundTextElement(element) || isBoundToContainer(element),
|
{(canHaveArrowheads(appState.activeTool.type) ||
|
||||||
) && renderAction("changeVerticalAlign")}
|
|
||||||
{(canHaveArrowheads(activeTool) ||
|
|
||||||
targetElements.some((element) => canHaveArrowheads(element.type))) && (
|
targetElements.some((element) => canHaveArrowheads(element.type))) && (
|
||||||
<>{renderAction("changeArrowhead")}</>
|
<>{renderAction("changeArrowhead")}</>
|
||||||
)}
|
)}
|
||||||
@@ -163,7 +168,16 @@ export const SelectedShapeActions = ({
|
|||||||
)}
|
)}
|
||||||
{targetElements.length > 2 &&
|
{targetElements.length > 2 &&
|
||||||
renderAction("distributeHorizontally")}
|
renderAction("distributeHorizontally")}
|
||||||
<div className="iconRow">
|
{/* breaks the row ˇˇ */}
|
||||||
|
<div style={{ flexBasis: "100%", height: 0 }} />
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexWrap: "wrap",
|
||||||
|
gap: ".5rem",
|
||||||
|
marginTop: "-0.5rem",
|
||||||
|
}}
|
||||||
|
>
|
||||||
{renderAction("alignTop")}
|
{renderAction("alignTop")}
|
||||||
{renderAction("alignVerticallyCentered")}
|
{renderAction("alignVerticallyCentered")}
|
||||||
{renderAction("alignBottom")}
|
{renderAction("alignBottom")}
|
||||||
@@ -203,25 +217,25 @@ export const ShapesSwitcher = ({
|
|||||||
appState: AppState;
|
appState: AppState;
|
||||||
}) => (
|
}) => (
|
||||||
<>
|
<>
|
||||||
{SHAPES.map(({ value, icon, key }, index) => {
|
{SHAPES.map(({ value, icon, key, numericKey, fillable }, index) => {
|
||||||
const label = t(`toolBar.${value}`);
|
const label = t(`toolBar.${value}`);
|
||||||
const letter = key && (typeof key === "string" ? key : key[0]);
|
const letter = key && (typeof key === "string" ? key : key[0]);
|
||||||
const shortcut = letter
|
const shortcut = letter
|
||||||
? `${capitalizeString(letter)} ${t("helpDialog.or")} ${index + 1}`
|
? `${capitalizeString(letter)} ${t("helpDialog.or")} ${numericKey}`
|
||||||
: `${index + 1}`;
|
: `${numericKey}`;
|
||||||
return (
|
return (
|
||||||
<ToolButton
|
<ToolButton
|
||||||
className="Shape"
|
className={clsx("Shape", { fillable })}
|
||||||
key={value}
|
key={value}
|
||||||
type="radio"
|
type="radio"
|
||||||
icon={icon}
|
icon={icon}
|
||||||
checked={activeTool.type === value}
|
checked={activeTool.type === value}
|
||||||
name="editor-current-shape"
|
name="editor-current-shape"
|
||||||
title={`${capitalizeString(label)} — ${shortcut}`}
|
title={`${capitalizeString(label)} — ${shortcut}`}
|
||||||
keyBindingLabel={`${index + 1}`}
|
keyBindingLabel={numericKey}
|
||||||
aria-label={capitalizeString(label)}
|
aria-label={capitalizeString(label)}
|
||||||
aria-keyshortcuts={shortcut}
|
aria-keyshortcuts={shortcut}
|
||||||
data-testid={value}
|
data-testid={`toolbar-${value}`}
|
||||||
onPointerDown={({ pointerType }) => {
|
onPointerDown={({ pointerType }) => {
|
||||||
if (!appState.penDetected && pointerType === "pen") {
|
if (!appState.penDetected && pointerType === "pen") {
|
||||||
setAppState({
|
setAppState({
|
||||||
@@ -263,11 +277,57 @@ export const ZoomActions = ({
|
|||||||
renderAction: ActionManager["renderAction"];
|
renderAction: ActionManager["renderAction"];
|
||||||
zoom: Zoom;
|
zoom: Zoom;
|
||||||
}) => (
|
}) => (
|
||||||
<Stack.Col gap={1}>
|
<Stack.Col gap={1} className="zoom-actions">
|
||||||
<Stack.Row gap={1} align="center">
|
<Stack.Row align="center">
|
||||||
{renderAction("zoomOut")}
|
{renderAction("zoomOut")}
|
||||||
{renderAction("zoomIn")}
|
|
||||||
{renderAction("resetZoom")}
|
{renderAction("resetZoom")}
|
||||||
|
{renderAction("zoomIn")}
|
||||||
</Stack.Row>
|
</Stack.Row>
|
||||||
</Stack.Col>
|
</Stack.Col>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const UndoRedoActions = ({
|
||||||
|
renderAction,
|
||||||
|
className,
|
||||||
|
}: {
|
||||||
|
renderAction: ActionManager["renderAction"];
|
||||||
|
className?: string;
|
||||||
|
}) => (
|
||||||
|
<div className={`undo-redo-buttons ${className}`}>
|
||||||
|
<div className="undo-button-container">
|
||||||
|
<Tooltip label={t("buttons.undo")}>{renderAction("undo")}</Tooltip>
|
||||||
|
</div>
|
||||||
|
<div className="redo-button-container">
|
||||||
|
<Tooltip label={t("buttons.redo")}> {renderAction("redo")}</Tooltip>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const ExitZenModeAction = ({
|
||||||
|
actionManager,
|
||||||
|
showExitZenModeBtn,
|
||||||
|
}: {
|
||||||
|
actionManager: ActionManager;
|
||||||
|
showExitZenModeBtn: boolean;
|
||||||
|
}) => (
|
||||||
|
<button
|
||||||
|
className={clsx("disable-zen-mode", {
|
||||||
|
"disable-zen-mode--visible": showExitZenModeBtn,
|
||||||
|
})}
|
||||||
|
onClick={() => actionManager.executeAction(actionToggleZenMode)}
|
||||||
|
>
|
||||||
|
{t("buttons.exitZenMode")}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const FinalizeAction = ({
|
||||||
|
renderAction,
|
||||||
|
className,
|
||||||
|
}: {
|
||||||
|
renderAction: ActionManager["renderAction"];
|
||||||
|
className?: string;
|
||||||
|
}) => (
|
||||||
|
<div className={`finalize-button ${className}`}>
|
||||||
|
{renderAction("finalize", { size: "small" })}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
import Stack from "../components/Stack";
|
// TODO barnabasmolnar/editor-redesign
|
||||||
import { ToolButton } from "../components/ToolButton";
|
// this icon is not great
|
||||||
import { save, file } from "../components/icons";
|
import { getShortcutFromShortcutName } from "../actions/shortcuts";
|
||||||
|
import { save } from "../components/icons";
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
|
|
||||||
import "./ActiveFile.scss";
|
import "./ActiveFile.scss";
|
||||||
|
import MenuItem from "./MenuItem";
|
||||||
|
|
||||||
type ActiveFileProps = {
|
type ActiveFileProps = {
|
||||||
fileName?: string;
|
fileName?: string;
|
||||||
@@ -11,18 +13,11 @@ type ActiveFileProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const ActiveFile = ({ fileName, onSave }: ActiveFileProps) => (
|
export const ActiveFile = ({ fileName, onSave }: ActiveFileProps) => (
|
||||||
<Stack.Row className="ActiveFile" gap={1} align="center">
|
<MenuItem
|
||||||
<span className="ActiveFile__fileName">
|
label={`${t("buttons.save")}`}
|
||||||
{file}
|
shortcut={getShortcutFromShortcutName("saveScene")}
|
||||||
<span>{fileName}</span>
|
dataTestId="save-button"
|
||||||
</span>
|
onClick={onSave}
|
||||||
<ToolButton
|
icon={save}
|
||||||
type="icon"
|
/>
|
||||||
icon={save}
|
|
||||||
title={t("buttons.save")}
|
|
||||||
aria-label={t("buttons.save")}
|
|
||||||
onClick={onSave}
|
|
||||||
data-testid="save-button"
|
|
||||||
/>
|
|
||||||
</Stack.Row>
|
|
||||||
);
|
);
|
||||||
|
@@ -2,21 +2,35 @@
|
|||||||
|
|
||||||
.excalidraw {
|
.excalidraw {
|
||||||
.Avatar {
|
.Avatar {
|
||||||
width: 2.5rem;
|
width: 1.25rem;
|
||||||
height: 2.5rem;
|
height: 1.25rem;
|
||||||
border-radius: 1.25rem;
|
position: relative;
|
||||||
|
border-radius: 100%;
|
||||||
|
outline-offset: 2px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: $oc-white;
|
color: $oc-white;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 0.8rem;
|
font-size: 0.625rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
line-height: 1;
|
||||||
|
|
||||||
&-img {
|
&-img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: -3px;
|
||||||
|
right: -3px;
|
||||||
|
bottom: -3px;
|
||||||
|
left: -3px;
|
||||||
|
border: 1px solid var(--avatar-border-color);
|
||||||
|
border-radius: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,13 +11,11 @@ type AvatarProps = {
|
|||||||
src?: string;
|
src?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Avatar = ({ color, border, onClick, name, src }: AvatarProps) => {
|
export const Avatar = ({ color, onClick, name, src }: AvatarProps) => {
|
||||||
const shortName = getClientInitials(name);
|
const shortName = getClientInitials(name);
|
||||||
const [error, setError] = useState(false);
|
const [error, setError] = useState(false);
|
||||||
const loadImg = !error && src;
|
const loadImg = !error && src;
|
||||||
const style = loadImg
|
const style = loadImg ? undefined : { background: color };
|
||||||
? undefined
|
|
||||||
: { background: color, border: `1px solid ${border}` };
|
|
||||||
return (
|
return (
|
||||||
<div className="Avatar" style={style} onClick={onClick}>
|
<div className="Avatar" style={style} onClick={onClick}>
|
||||||
{loadImg ? (
|
{loadImg ? (
|
||||||
|
@@ -1,20 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import { ActionManager } from "../actions/manager";
|
|
||||||
import { AppState } from "../types";
|
|
||||||
|
|
||||||
export const BackgroundPickerAndDarkModeToggle = ({
|
|
||||||
appState,
|
|
||||||
setAppState,
|
|
||||||
actionManager,
|
|
||||||
showThemeBtn,
|
|
||||||
}: {
|
|
||||||
actionManager: ActionManager;
|
|
||||||
appState: AppState;
|
|
||||||
setAppState: React.Component<any, AppState>["setState"];
|
|
||||||
showThemeBtn: boolean;
|
|
||||||
}) => (
|
|
||||||
<div style={{ display: "flex" }}>
|
|
||||||
{actionManager.renderAction("changeViewBackgroundColor")}
|
|
||||||
{showThemeBtn && actionManager.renderAction("toggleTheme")}
|
|
||||||
</div>
|
|
||||||
);
|
|
@@ -4,6 +4,7 @@ import "./Card.scss";
|
|||||||
|
|
||||||
export const Card: React.FC<{
|
export const Card: React.FC<{
|
||||||
color: keyof OpenColor | "primary";
|
color: keyof OpenColor | "primary";
|
||||||
|
children?: React.ReactNode;
|
||||||
}> = ({ children, color }) => {
|
}> = ({ children, color }) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@@ -64,6 +64,8 @@
|
|||||||
|
|
||||||
color: #{$oc-blue-7};
|
color: #{$oc-blue-7};
|
||||||
|
|
||||||
|
border: 0;
|
||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
box-shadow: 0 0 0 3px #{$oc-blue-7};
|
box-shadow: 0 0 0 3px #{$oc-blue-7};
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,7 @@ export const CheckboxItem: React.FC<{
|
|||||||
checked: boolean;
|
checked: boolean;
|
||||||
onChange: (checked: boolean, event: React.MouseEvent) => void;
|
onChange: (checked: boolean, event: React.MouseEvent) => void;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
children?: React.ReactNode;
|
||||||
}> = ({ children, checked, onChange, className }) => {
|
}> = ({ children, checked, onChange, className }) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@@ -1,10 +1,9 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { useDevice } from "./App";
|
import { TrashIcon } from "./icons";
|
||||||
import { trash } from "./icons";
|
|
||||||
import { ToolButton } from "./ToolButton";
|
|
||||||
|
|
||||||
import ConfirmDialog from "./ConfirmDialog";
|
import ConfirmDialog from "./ConfirmDialog";
|
||||||
|
import MenuItem from "./MenuItem";
|
||||||
|
|
||||||
const ClearCanvas = ({ onConfirm }: { onConfirm: () => void }) => {
|
const ClearCanvas = ({ onConfirm }: { onConfirm: () => void }) => {
|
||||||
const [showDialog, setShowDialog] = useState(false);
|
const [showDialog, setShowDialog] = useState(false);
|
||||||
@@ -14,14 +13,11 @@ const ClearCanvas = ({ onConfirm }: { onConfirm: () => void }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ToolButton
|
<MenuItem
|
||||||
type="button"
|
label={t("buttons.clearReset")}
|
||||||
icon={trash}
|
icon={TrashIcon}
|
||||||
title={t("buttons.clearReset")}
|
|
||||||
aria-label={t("buttons.clearReset")}
|
|
||||||
showAriaLabel={useDevice().isMobile}
|
|
||||||
onClick={toggleDialog}
|
onClick={toggleDialog}
|
||||||
data-testid="clear-canvas-button"
|
dataTestId="clear-canvas-button"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{showDialog && (
|
{showDialog && (
|
||||||
|
@@ -1,6 +1,51 @@
|
|||||||
@import "../css/variables.module";
|
@import "../css/variables.module";
|
||||||
|
|
||||||
.excalidraw {
|
.excalidraw {
|
||||||
|
.collab-button {
|
||||||
|
@include outlineButtonStyles;
|
||||||
|
width: var(--lg-button-size);
|
||||||
|
height: var(--lg-button-size);
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: var(--lg-icon-size);
|
||||||
|
height: var(--lg-icon-size);
|
||||||
|
}
|
||||||
|
background-color: var(--color-primary);
|
||||||
|
border-color: var(--color-primary);
|
||||||
|
color: white;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--color-primary-darker);
|
||||||
|
border-color: var(--color-primary-darker);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
background-color: var(--color-primary-darker);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background-color: #0fb884;
|
||||||
|
border-color: #0fb884;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:active {
|
||||||
|
background-color: #0fb884;
|
||||||
|
border-color: #0fb884;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.theme--dark {
|
||||||
|
.collab-button {
|
||||||
|
color: var(--color-gray-90);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.CollabButton.is-collaborating {
|
.CollabButton.is-collaborating {
|
||||||
background-color: var(--button-special-active-bg-color);
|
background-color: var(--button-special-active-bg-color);
|
||||||
|
|
||||||
@@ -24,9 +69,9 @@
|
|||||||
bottom: -5px;
|
bottom: -5px;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background-color: $oc-green-6;
|
background-color: $oc-green-2;
|
||||||
color: $oc-white;
|
color: $oc-green-9;
|
||||||
font-size: 0.6em;
|
font-size: 0.6rem;
|
||||||
font-family: "Cascadia";
|
font-family: "Cascadia";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,37 +1,47 @@
|
|||||||
import clsx from "clsx";
|
|
||||||
import { ToolButton } from "./ToolButton";
|
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { useDevice } from "../components/App";
|
import { UsersIcon } from "./icons";
|
||||||
import { users } from "./icons";
|
|
||||||
|
|
||||||
import "./CollabButton.scss";
|
import "./CollabButton.scss";
|
||||||
|
import MenuItem from "./MenuItem";
|
||||||
|
import clsx from "clsx";
|
||||||
|
|
||||||
const CollabButton = ({
|
const CollabButton = ({
|
||||||
isCollaborating,
|
isCollaborating,
|
||||||
collaboratorCount,
|
collaboratorCount,
|
||||||
onClick,
|
onClick,
|
||||||
|
isInHamburgerMenu = true,
|
||||||
}: {
|
}: {
|
||||||
isCollaborating: boolean;
|
isCollaborating: boolean;
|
||||||
collaboratorCount: number;
|
collaboratorCount: number;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
|
isInHamburgerMenu?: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ToolButton
|
{isInHamburgerMenu ? (
|
||||||
className={clsx("CollabButton", {
|
<MenuItem
|
||||||
"is-collaborating": isCollaborating,
|
label={t("labels.liveCollaboration")}
|
||||||
})}
|
dataTestId="collab-button"
|
||||||
onClick={onClick}
|
icon={UsersIcon}
|
||||||
icon={users}
|
onClick={onClick}
|
||||||
type="button"
|
isCollaborating={isCollaborating}
|
||||||
title={t("labels.liveCollaboration")}
|
/>
|
||||||
aria-label={t("labels.liveCollaboration")}
|
) : (
|
||||||
showAriaLabel={useDevice().isMobile}
|
<button
|
||||||
>
|
className={clsx("collab-button", { active: isCollaborating })}
|
||||||
{isCollaborating && (
|
type="button"
|
||||||
<div className="CollabButton-collaborators">{collaboratorCount}</div>
|
onClick={onClick}
|
||||||
)}
|
style={{ position: "relative" }}
|
||||||
</ToolButton>
|
title={t("labels.liveCollaboration")}
|
||||||
|
>
|
||||||
|
{UsersIcon}
|
||||||
|
{collaboratorCount > 0 && (
|
||||||
|
<div className="CollabButton-collaborators">
|
||||||
|
{collaboratorCount}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@@ -21,6 +21,23 @@
|
|||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: auto 1fr;
|
grid-template-columns: auto 1fr;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
column-gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-picker-control-container + .popover {
|
||||||
|
position: static;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-picker-popover-container {
|
||||||
|
margin-top: -0.25rem;
|
||||||
|
|
||||||
|
:root[dir="ltr"] & {
|
||||||
|
margin-left: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[dir="rtl"] & {
|
||||||
|
margin-left: -3rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.color-picker-triangle {
|
.color-picker-triangle {
|
||||||
@@ -30,20 +47,29 @@
|
|||||||
border-width: 0 9px 10px;
|
border-width: 0 9px 10px;
|
||||||
border-color: transparent transparent var(--popup-bg-color);
|
border-color: transparent transparent var(--popup-bg-color);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -10px;
|
top: 10px;
|
||||||
|
|
||||||
:root[dir="ltr"] & {
|
:root[dir="ltr"] & {
|
||||||
left: 12px;
|
transform: rotate(270deg);
|
||||||
|
left: -14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
:root[dir="rtl"] & {
|
:root[dir="rtl"] & {
|
||||||
right: 12px;
|
transform: rotate(90deg);
|
||||||
|
right: -14px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.color-picker-triangle-shadow {
|
.color-picker-triangle-shadow {
|
||||||
border-color: transparent transparent transparentize($oc-black, 0.9);
|
border-color: transparent transparent transparentize($oc-black, 0.9);
|
||||||
top: -11px;
|
|
||||||
|
:root[dir="ltr"] & {
|
||||||
|
left: -14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root[dir="rtl"] & {
|
||||||
|
right: -16px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.color-picker-content--default {
|
.color-picker-content--default {
|
||||||
@@ -119,16 +145,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.color-picker-hash {
|
.color-picker-hash {
|
||||||
background: var(--input-border-color);
|
height: var(--default-button-size);
|
||||||
height: 1.875rem;
|
flex-shrink: 0;
|
||||||
width: 1.875rem;
|
padding: 0.5rem 0.5rem 0.5rem 0.75rem;
|
||||||
|
border: 1px solid var(--default-border-color);
|
||||||
|
border-right: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
:root[dir="ltr"] & {
|
:root[dir="ltr"] & {
|
||||||
border-radius: 4px 0 0 4px;
|
border-radius: var(--border-radius-lg) 0 0 var(--border-radius-lg);
|
||||||
}
|
}
|
||||||
|
|
||||||
:root[dir="rtl"] & {
|
:root[dir="rtl"] & {
|
||||||
border-radius: 0 4px 4px 0;
|
border-radius: 0 var(--border-radius-lg) var(--border-radius-lg) 0;
|
||||||
|
border-right: 1px solid var(--default-border-color);
|
||||||
|
border-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
color: var(--input-label-color);
|
color: var(--input-label-color);
|
||||||
@@ -138,81 +169,64 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.color-input-container:focus-within .color-picker-hash {
|
|
||||||
box-shadow: 0 0 0 2px var(--focus-highlight-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.color-input-container:focus-within .color-picker-hash::before,
|
|
||||||
.color-input-container:focus-within .color-picker-hash::after {
|
|
||||||
content: "";
|
|
||||||
width: 1px;
|
|
||||||
height: 100%;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.color-input-container:focus-within .color-picker-hash::before {
|
|
||||||
background: var(--input-border-color);
|
|
||||||
|
|
||||||
:root[dir="ltr"] & {
|
|
||||||
right: -1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root[dir="rtl"] & {
|
|
||||||
left: -1px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.color-input-container:focus-within .color-picker-hash::after {
|
|
||||||
background: var(--input-bg-color);
|
|
||||||
|
|
||||||
:root[dir="ltr"] & {
|
|
||||||
right: -2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root[dir="rtl"] & {
|
|
||||||
left: -2px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.color-input-container {
|
.color-input-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
|
&:focus-within {
|
||||||
|
box-shadow: 0 0 0 1px var(--color-primary-darkest);
|
||||||
|
border-radius: var(--border-radius-lg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.color-picker-input {
|
.color-picker-input {
|
||||||
width: 11ch; /* length of `transparent` */
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 1rem;
|
font-size: 0.875rem;
|
||||||
background-color: var(--input-bg-color);
|
background-color: transparent;
|
||||||
color: var(--text-primary-color);
|
color: var(--text-primary-color);
|
||||||
border: 0;
|
border: 0;
|
||||||
outline: none;
|
outline: none;
|
||||||
height: 1.75em;
|
height: var(--default-button-size);
|
||||||
box-shadow: var(--input-border-color) 0 0 0 1px inset;
|
border: 1px solid var(--default-border-color);
|
||||||
|
border-left: 0;
|
||||||
|
letter-spacing: 0.4px;
|
||||||
|
|
||||||
:root[dir="ltr"] & {
|
:root[dir="ltr"] & {
|
||||||
border-radius: 0 4px 4px 0;
|
border-radius: 0 var(--border-radius-lg) var(--border-radius-lg) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
:root[dir="rtl"] & {
|
:root[dir="rtl"] & {
|
||||||
border-radius: 4px 0 0 4px;
|
border-radius: var(--border-radius-lg) 0 0 var(--border-radius-lg);
|
||||||
|
border-left: 1px solid var(--default-border-color);
|
||||||
|
border-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float: left;
|
padding: 0.5rem;
|
||||||
padding: 1px;
|
padding-left: 0.25rem;
|
||||||
padding-inline-start: 0.5em;
|
|
||||||
appearance: none;
|
appearance: none;
|
||||||
|
|
||||||
|
&:focus-visible {
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-picker-label-swatch-container {
|
||||||
|
border: 1px solid var(--default-border-color);
|
||||||
|
border-radius: var(--border-radius-lg);
|
||||||
|
width: var(--default-button-size);
|
||||||
|
height: var(--default-button-size);
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.color-picker-label-swatch {
|
.color-picker-label-swatch {
|
||||||
height: 1.875rem;
|
@include outlineButtonStyles;
|
||||||
width: 1.875rem;
|
background-color: var(--swatch-color) !important;
|
||||||
margin-inline-end: 0.25rem;
|
|
||||||
border: 1px solid $oc-gray-3;
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background-color: transparent !important;
|
position: relative;
|
||||||
filter: var(--theme-filter);
|
filter: var(--theme-filter);
|
||||||
|
border: 0 !important;
|
||||||
|
|
||||||
&:after {
|
&:after {
|
||||||
content: "";
|
content: "";
|
||||||
|
@@ -66,10 +66,13 @@ const getColor = (color: string): string | null => {
|
|||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isValidColor(color)
|
// testing for `#` first fixes a bug on Electron (more specfically, an
|
||||||
? color
|
// Obsidian popout window), where a hex color without `#` is (incorrectly)
|
||||||
: isValidColor(`#${color}`)
|
// considered valid
|
||||||
|
return isValidColor(`#${color}`)
|
||||||
? `#${color}`
|
? `#${color}`
|
||||||
|
: isValidColor(color)
|
||||||
|
? color
|
||||||
: null;
|
: null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -343,6 +346,8 @@ const ColorInput = React.forwardRef(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ColorInput.displayName = "ColorInput";
|
||||||
|
|
||||||
export const ColorPicker = ({
|
export const ColorPicker = ({
|
||||||
type,
|
type,
|
||||||
color,
|
color,
|
||||||
@@ -363,17 +368,20 @@ export const ColorPicker = ({
|
|||||||
appState: AppState;
|
appState: AppState;
|
||||||
}) => {
|
}) => {
|
||||||
const pickerButton = React.useRef<HTMLButtonElement>(null);
|
const pickerButton = React.useRef<HTMLButtonElement>(null);
|
||||||
|
const coords = pickerButton.current?.getBoundingClientRect();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="color-picker-control-container">
|
<div className="color-picker-control-container">
|
||||||
<button
|
<div className="color-picker-label-swatch-container">
|
||||||
className="color-picker-label-swatch"
|
<button
|
||||||
aria-label={label}
|
className="color-picker-label-swatch"
|
||||||
style={color ? { "--swatch-color": color } : undefined}
|
aria-label={label}
|
||||||
onClick={() => setActive(!isActive)}
|
style={color ? { "--swatch-color": color } : undefined}
|
||||||
ref={pickerButton}
|
onClick={() => setActive(!isActive)}
|
||||||
/>
|
ref={pickerButton}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<ColorInput
|
<ColorInput
|
||||||
color={color}
|
color={color}
|
||||||
label={label}
|
label={label}
|
||||||
@@ -384,27 +392,37 @@ export const ColorPicker = ({
|
|||||||
</div>
|
</div>
|
||||||
<React.Suspense fallback="">
|
<React.Suspense fallback="">
|
||||||
{isActive ? (
|
{isActive ? (
|
||||||
<Popover
|
<div
|
||||||
onCloseRequest={(event) =>
|
className="color-picker-popover-container"
|
||||||
event.target !== pickerButton.current && setActive(false)
|
style={{
|
||||||
}
|
position: "fixed",
|
||||||
|
top: coords?.top,
|
||||||
|
left: coords?.right,
|
||||||
|
zIndex: 1,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Picker
|
<Popover
|
||||||
colors={colors[type]}
|
onCloseRequest={(event) =>
|
||||||
color={color || null}
|
event.target !== pickerButton.current && setActive(false)
|
||||||
onChange={(changedColor) => {
|
}
|
||||||
onChange(changedColor);
|
>
|
||||||
}}
|
<Picker
|
||||||
onClose={() => {
|
colors={colors[type]}
|
||||||
setActive(false);
|
color={color || null}
|
||||||
pickerButton.current?.focus();
|
onChange={(changedColor) => {
|
||||||
}}
|
onChange(changedColor);
|
||||||
label={label}
|
}}
|
||||||
showInput={false}
|
onClose={() => {
|
||||||
type={type}
|
setActive(false);
|
||||||
elements={elements}
|
pickerButton.current?.focus();
|
||||||
/>
|
}}
|
||||||
</Popover>
|
label={label}
|
||||||
|
showInput={false}
|
||||||
|
type={type}
|
||||||
|
elements={elements}
|
||||||
|
/>
|
||||||
|
</Popover>
|
||||||
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</React.Suspense>
|
</React.Suspense>
|
||||||
</div>
|
</div>
|
||||||
|