Compare commits
93 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a07ac46f8d | |||
| 157bb7d6d6 | |||
| d0b33d35db | |||
| d6a5ef1936 | |||
| c7a11f5cd2 | |||
| 893c487add | |||
| 99fdffdab7 | |||
| faad8a65f1 | |||
| 9d04479f98 | |||
| 599a8f3c6f | |||
| 0982da38fe | |||
| 699897f71b | |||
| 328ff6c32d | |||
| 618442299f | |||
| 06b45e0cfc | |||
| 809d5ba17f | |||
| 40d53d9231 | |||
| 9803a85381 | |||
| 72784f9d29 | |||
| e3249f930c | |||
| cbe0d34f1a | |||
| bed8093e47 | |||
| 1255ca2e84 | |||
| 14d02dcaea | |||
| 9747223705 | |||
| 0f11f7da15 | |||
| 8420aecb34 | |||
| 08afb857c3 | |||
| 9230c8f4d2 | |||
| dba8f812f1 | |||
| fdd8552637 | |||
| c8370b394c | |||
| 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 |
+2
-1
@@ -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,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:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name: Build Docker image
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- release
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-docker:
|
build-docker:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name: Cancel previous runs
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- release
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name: Publish Docker
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- release
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-docker:
|
publish-docker:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ name: New Sentry production release
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- release
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
sentry:
|
sentry:
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
yarn lint-staged
|
# yarn lint-staged
|
||||||
|
|||||||
+6
-6
@@ -4692,9 +4692,9 @@ json-schema-traverse@^1.0.0:
|
|||||||
integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==
|
integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==
|
||||||
|
|
||||||
json5@^2.1.2, json5@^2.2.1:
|
json5@^2.1.2, json5@^2.2.1:
|
||||||
version "2.2.1"
|
version "2.2.3"
|
||||||
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c"
|
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
|
||||||
integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==
|
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
|
||||||
|
|
||||||
jsonfile@^6.0.1:
|
jsonfile@^6.0.1:
|
||||||
version "6.1.0"
|
version "6.1.0"
|
||||||
@@ -4755,9 +4755,9 @@ loader-runner@^4.2.0:
|
|||||||
integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==
|
integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==
|
||||||
|
|
||||||
loader-utils@^2.0.0:
|
loader-utils@^2.0.0:
|
||||||
version "2.0.2"
|
version "2.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.2.tgz#d6e3b4fb81870721ae4e0868ab11dd638368c129"
|
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.4.tgz#8b5cb38b5c34a9a018ee1fc0e6a066d1dfcc528c"
|
||||||
integrity sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==
|
integrity sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==
|
||||||
dependencies:
|
dependencies:
|
||||||
big.js "^5.2.2"
|
big.js "^5.2.2"
|
||||||
emojis-list "^3.0.0"
|
emojis-list "^3.0.0"
|
||||||
|
|||||||
+20
-6
@@ -31,6 +31,7 @@
|
|||||||
"@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.4",
|
"i18next-browser-languagedetector": "6.1.4",
|
||||||
@@ -50,11 +51,23 @@
|
|||||||
"pwacompat": "2.0.17",
|
"pwacompat": "2.0.17",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
"react-dom": "18.2.0",
|
"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",
|
||||||
@@ -67,6 +80,7 @@
|
|||||||
"dotenv": "16.0.1",
|
"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",
|
||||||
@@ -89,11 +103,10 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"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": "cross-env REACT_APP_DISABLE_SENTRY=true REACT_APP_DISABLE_TRACKING=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",
|
||||||
@@ -103,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 .",
|
||||||
|
|||||||
+2
-1
@@ -146,7 +146,8 @@
|
|||||||
// setting this so that libraries installation reuses this window tab.
|
// setting this so that libraries installation reuses this window tab.
|
||||||
window.name = "_excalidraw";
|
window.name = "_excalidraw";
|
||||||
</script>
|
</script>
|
||||||
<% if (process.env.REACT_APP_GOOGLE_ANALYTICS_ID) { %>
|
<% if (process.env.REACT_APP_DISABLE_TRACKING !== 'true' &&
|
||||||
|
process.env.REACT_APP_GOOGLE_ANALYTICS_ID) { %>
|
||||||
<script
|
<script
|
||||||
async
|
async
|
||||||
src="https://www.googletagmanager.com/gtag/js?id=%REACT_APP_GOOGLE_ANALYTICS_ID%"
|
src="https://www.googletagmanager.com/gtag/js?id=%REACT_APP_GOOGLE_ANALYTICS_ID%"
|
||||||
|
|||||||
@@ -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);
|
|
||||||
})(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -50,8 +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",
|
"vi-VN": "en-vi",
|
||||||
"mr-in": "en-mr",
|
"mr-IN": "en-mr",
|
||||||
};
|
};
|
||||||
|
|
||||||
const flags = {
|
const flags = {
|
||||||
@@ -120,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",
|
||||||
@@ -129,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",
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
const fs = require("fs");
|
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
// 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 = path.resolve(__dirname, "../public/service-worker.js");
|
|
||||||
const newPath = path.resolve(__dirname, "../src/service-worker.js");
|
|
||||||
|
|
||||||
fs.rename(oldPath, newPath, (error) => {
|
|
||||||
if (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
console.info("public/service-worker.js moved to src/");
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
moveServiceWorkerScript();
|
|
||||||
@@ -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,
|
||||||
@@ -22,7 +26,7 @@ export const actionUnbindText = register({
|
|||||||
name: "unbindText",
|
name: "unbindText",
|
||||||
contextItemLabel: "labels.unbindText",
|
contextItemLabel: "labels.unbindText",
|
||||||
trackEvent: { category: "element" },
|
trackEvent: { category: "element" },
|
||||||
contextItemPredicate: (elements, appState) => {
|
predicate: (elements, appState) => {
|
||||||
const selectedElements = getSelectedElements(elements, appState);
|
const selectedElements = getSelectedElements(elements, appState);
|
||||||
return selectedElements.some((element) => hasBoundTextElement(element));
|
return selectedElements.some((element) => hasBoundTextElement(element));
|
||||||
},
|
},
|
||||||
@@ -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,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -64,7 +76,7 @@ export const actionBindText = register({
|
|||||||
name: "bindText",
|
name: "bindText",
|
||||||
contextItemLabel: "labels.bindText",
|
contextItemLabel: "labels.bindText",
|
||||||
trackEvent: { category: "element" },
|
trackEvent: { category: "element" },
|
||||||
contextItemPredicate: (elements, appState) => {
|
predicate: (elements, appState) => {
|
||||||
const selectedElements = getSelectedElements(elements, appState);
|
const selectedElements = getSelectedElements(elements, appState);
|
||||||
|
|
||||||
if (selectedElements.length === 2) {
|
if (selectedElements.length === 2) {
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
import { ColorPicker } from "../components/ColorPicker";
|
import { ColorPicker } from "../components/ColorPicker";
|
||||||
import {
|
import { eraser, ZoomInIcon, ZoomOutIcon } from "../components/icons";
|
||||||
eraser,
|
|
||||||
MoonIcon,
|
|
||||||
SunIcon,
|
|
||||||
ZoomInIcon,
|
|
||||||
ZoomOutIcon,
|
|
||||||
} from "../components/icons";
|
|
||||||
import { ToolButton } from "../components/ToolButton";
|
import { ToolButton } from "../components/ToolButton";
|
||||||
import { MIN_ZOOM, THEME, ZOOM_STEP } from "../constants";
|
import { MIN_ZOOM, THEME, ZOOM_STEP } from "../constants";
|
||||||
import { getCommonBounds, getNonDeletedElements } from "../element";
|
import { getCommonBounds, getNonDeletedElements } from "../element";
|
||||||
@@ -21,14 +15,17 @@ import { register } from "./register";
|
|||||||
import { Tooltip } from "../components/Tooltip";
|
import { Tooltip } from "../components/Tooltip";
|
||||||
import { newElementWith } from "../element/mutateElement";
|
import { newElementWith } from "../element/mutateElement";
|
||||||
import { getDefaultAppState, isEraserActive } from "../appState";
|
import { getDefaultAppState, isEraserActive } from "../appState";
|
||||||
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",
|
||||||
trackEvent: false,
|
trackEvent: false,
|
||||||
|
predicate: (elements, appState, props, app) => {
|
||||||
|
return (
|
||||||
|
!!app.props.UIOptions.canvasActions.changeViewBackgroundColor &&
|
||||||
|
!appState.viewModeEnabled
|
||||||
|
);
|
||||||
|
},
|
||||||
perform: (_, appState, value) => {
|
perform: (_, appState, value) => {
|
||||||
return {
|
return {
|
||||||
appState: { ...appState, ...value },
|
appState: { ...appState, ...value },
|
||||||
@@ -36,6 +33,7 @@ export const actionChangeViewBackgroundColor = register({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
PanelComponent: ({ elements, appState, updateData }) => {
|
PanelComponent: ({ elements, appState, updateData }) => {
|
||||||
|
// FIXME move me to src/components/mainMenu/DefaultItems.tsx
|
||||||
return (
|
return (
|
||||||
<div style={{ position: "relative" }}>
|
<div style={{ position: "relative" }}>
|
||||||
<ColorPicker
|
<ColorPicker
|
||||||
@@ -59,6 +57,12 @@ export const actionChangeViewBackgroundColor = register({
|
|||||||
export const actionClearCanvas = register({
|
export const actionClearCanvas = register({
|
||||||
name: "clearCanvas",
|
name: "clearCanvas",
|
||||||
trackEvent: { category: "canvas" },
|
trackEvent: { category: "canvas" },
|
||||||
|
predicate: (elements, appState, props, app) => {
|
||||||
|
return (
|
||||||
|
!!app.props.UIOptions.canvasActions.clearCanvas &&
|
||||||
|
!appState.viewModeEnabled
|
||||||
|
);
|
||||||
|
},
|
||||||
perform: (elements, appState, _, app) => {
|
perform: (elements, appState, _, app) => {
|
||||||
app.imageCache.clear();
|
app.imageCache.clear();
|
||||||
return {
|
return {
|
||||||
@@ -84,12 +88,11 @@ export const actionClearCanvas = register({
|
|||||||
commitToHistory: true,
|
commitToHistory: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
PanelComponent: ({ updateData }) => <ClearCanvas onConfirm={updateData} />,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
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 {
|
||||||
@@ -126,6 +129,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 {
|
||||||
@@ -162,6 +166,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 {
|
||||||
@@ -271,6 +276,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) =>
|
||||||
@@ -282,6 +288,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 {
|
||||||
@@ -293,22 +300,10 @@ export const actionToggleTheme = register({
|
|||||||
commitToHistory: false,
|
commitToHistory: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
PanelComponent: ({ appState, updateData }) => (
|
|
||||||
<MenuItem
|
|
||||||
label={
|
|
||||||
appState.theme === "dark"
|
|
||||||
? t("buttons.lightMode")
|
|
||||||
: t("buttons.darkMode")
|
|
||||||
}
|
|
||||||
onClick={() => {
|
|
||||||
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,
|
||||||
|
predicate: (elements, appState, props, app) => {
|
||||||
|
return !!app.props.UIOptions.canvasActions.toggleTheme;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const actionErase = register({
|
export const actionErase = register({
|
||||||
|
|||||||
@@ -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,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
predicate: (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,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
predicate: (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,6 +56,9 @@ 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);
|
||||||
},
|
},
|
||||||
|
predicate: (elements, appState, appProps, app) => {
|
||||||
|
return app.device.isMobile && !!navigator.clipboard;
|
||||||
|
},
|
||||||
contextItemLabel: "labels.cut",
|
contextItemLabel: "labels.cut",
|
||||||
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.key === KEYS.X,
|
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.key === KEYS.X,
|
||||||
});
|
});
|
||||||
@@ -77,6 +101,9 @@ export const actionCopyAsSvg = register({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
predicate: (elements) => {
|
||||||
|
return probablySupportsClipboardWriteText && elements.length > 0;
|
||||||
|
},
|
||||||
contextItemLabel: "labels.copyAsSvg",
|
contextItemLabel: "labels.copyAsSvg",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -131,6 +158,9 @@ export const actionCopyAsPng = register({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
predicate: (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,
|
||||||
});
|
});
|
||||||
@@ -158,7 +188,7 @@ export const copyText = register({
|
|||||||
commitToHistory: false,
|
commitToHistory: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
contextItemPredicate: (elements, appState) => {
|
predicate: (elements, appState) => {
|
||||||
return (
|
return (
|
||||||
probablySupportsClipboardWriteText &&
|
probablySupportsClipboardWriteText &&
|
||||||
getSelectedElements(elements, appState, true).some(isTextElement)
|
getSelectedElements(elements, appState, true).some(isTextElement)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { LoadIcon, questionCircle, saveAs } from "../components/icons";
|
import { 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 { Tooltip } from "../components/Tooltip";
|
import { Tooltip } from "../components/Tooltip";
|
||||||
import { DarkModeToggle } from "../components/DarkModeToggle";
|
import { DarkModeToggle } from "../components/DarkModeToggle";
|
||||||
import { loadFromJSON, saveAsJSON } from "../data";
|
import { loadFromJSON, saveAsJSON } from "../data";
|
||||||
@@ -15,12 +14,11 @@ import { getExportSize } from "../scene/export";
|
|||||||
import { DEFAULT_EXPORT_PADDING, EXPORT_SCALES, THEME } from "../constants";
|
import { DEFAULT_EXPORT_PADDING, EXPORT_SCALES, THEME } from "../constants";
|
||||||
import { getSelectedElements, isSomeElementSelected } from "../scene";
|
import { getSelectedElements, isSomeElementSelected } from "../scene";
|
||||||
import { getNonDeletedElements } from "../element";
|
import { getNonDeletedElements } from "../element";
|
||||||
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";
|
import "../components/ToolIcon.scss";
|
||||||
|
|
||||||
export const actionChangeProjectName = register({
|
export const actionChangeProjectName = register({
|
||||||
name: "changeProjectName",
|
name: "changeProjectName",
|
||||||
@@ -133,6 +131,13 @@ export const actionChangeExportEmbedScene = register({
|
|||||||
export const actionSaveToActiveFile = register({
|
export const actionSaveToActiveFile = register({
|
||||||
name: "saveToActiveFile",
|
name: "saveToActiveFile",
|
||||||
trackEvent: { category: "export" },
|
trackEvent: { category: "export" },
|
||||||
|
predicate: (elements, appState, props, app) => {
|
||||||
|
return (
|
||||||
|
!!app.props.UIOptions.canvasActions.saveToActiveFile &&
|
||||||
|
!!appState.fileHandle &&
|
||||||
|
!appState.viewModeEnabled
|
||||||
|
);
|
||||||
|
},
|
||||||
perform: async (elements, appState, value, app) => {
|
perform: async (elements, appState, value, app) => {
|
||||||
const fileHandleExists = !!appState.fileHandle;
|
const fileHandleExists = !!appState.fileHandle;
|
||||||
|
|
||||||
@@ -169,16 +174,11 @@ export const actionSaveToActiveFile = register({
|
|||||||
},
|
},
|
||||||
keyTest: (event) =>
|
keyTest: (event) =>
|
||||||
event.key === KEYS.S && event[KEYS.CTRL_OR_CMD] && !event.shiftKey,
|
event.key === KEYS.S && event[KEYS.CTRL_OR_CMD] && !event.shiftKey,
|
||||||
PanelComponent: ({ updateData, appState }) => (
|
|
||||||
<ActiveFile
|
|
||||||
onSave={() => updateData(null)}
|
|
||||||
fileName={appState.fileHandle?.name}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
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 {
|
||||||
@@ -219,6 +219,11 @@ export const actionSaveFileToDisk = register({
|
|||||||
export const actionLoadScene = register({
|
export const actionLoadScene = register({
|
||||||
name: "loadScene",
|
name: "loadScene",
|
||||||
trackEvent: { category: "export" },
|
trackEvent: { category: "export" },
|
||||||
|
predicate: (elements, appState, props, app) => {
|
||||||
|
return (
|
||||||
|
!!app.props.UIOptions.canvasActions.loadScene && !appState.viewModeEnabled
|
||||||
|
);
|
||||||
|
},
|
||||||
perform: async (elements, appState, _, app) => {
|
perform: async (elements, appState, _, app) => {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
@@ -246,15 +251,6 @@ 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 }) => (
|
|
||||||
<MenuItem
|
|
||||||
label={t("buttons.load")}
|
|
||||||
icon={LoadIcon}
|
|
||||||
onClick={updateData}
|
|
||||||
dataTestId="load-button"
|
|
||||||
shortcut={getShortcutFromShortcutName("loadScene")}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const actionExportWithDarkMode = register({
|
export const actionExportWithDarkMode = register({
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
} from "../element/bounds";
|
} from "../element/bounds";
|
||||||
import { isLinearElement } from "../element/typeChecks";
|
import { isLinearElement } from "../element/typeChecks";
|
||||||
import { LinearElementEditor } from "../element/linearElementEditor";
|
import { LinearElementEditor } from "../element/linearElementEditor";
|
||||||
|
import { KEYS } from "../keys";
|
||||||
|
|
||||||
const enableActionFlipHorizontal = (
|
const enableActionFlipHorizontal = (
|
||||||
elements: readonly ExcalidrawElement[],
|
elements: readonly ExcalidrawElement[],
|
||||||
@@ -49,7 +50,7 @@ export const actionFlipHorizontal = register({
|
|||||||
},
|
},
|
||||||
keyTest: (event) => event.shiftKey && event.code === "KeyH",
|
keyTest: (event) => event.shiftKey && event.code === "KeyH",
|
||||||
contextItemLabel: "labels.flipHorizontal",
|
contextItemLabel: "labels.flipHorizontal",
|
||||||
contextItemPredicate: (elements, appState) =>
|
predicate: (elements, appState) =>
|
||||||
enableActionFlipHorizontal(elements, appState),
|
enableActionFlipHorizontal(elements, appState),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -63,9 +64,10 @@ 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) =>
|
predicate: (elements, appState) =>
|
||||||
enableActionFlipVertical(elements, appState),
|
enableActionFlipVertical(elements, appState),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -151,11 +153,7 @@ const flipElement = (
|
|||||||
|
|
||||||
let initialPointsCoords;
|
let initialPointsCoords;
|
||||||
if (isLinearElement(element)) {
|
if (isLinearElement(element)) {
|
||||||
initialPointsCoords = getElementPointsCoords(
|
initialPointsCoords = getElementPointsCoords(element, element.points);
|
||||||
element,
|
|
||||||
element.points,
|
|
||||||
element.strokeSharpness,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
const initialElementAbsoluteCoords = getElementAbsoluteCoords(element);
|
const initialElementAbsoluteCoords = getElementAbsoluteCoords(element);
|
||||||
|
|
||||||
@@ -213,11 +211,7 @@ const flipElement = (
|
|||||||
// Adjusting origin because when a beizer curve path exceeds min/max points it offsets the origin.
|
// 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
|
// 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.
|
// we still have a small offset of the origin when fliipping the element.
|
||||||
const finalPointsCoords = getElementPointsCoords(
|
const finalPointsCoords = getElementPointsCoords(element, element.points);
|
||||||
element,
|
|
||||||
element.points,
|
|
||||||
element.strokeSharpness,
|
|
||||||
);
|
|
||||||
|
|
||||||
const topLeftCoordsDiff = initialPointsCoords[0] - finalPointsCoords[0];
|
const topLeftCoordsDiff = initialPointsCoords[0] - finalPointsCoords[0];
|
||||||
const topRightCoordDiff = initialPointsCoords[2] - finalPointsCoords[2];
|
const topRightCoordDiff = initialPointsCoords[2] - finalPointsCoords[2];
|
||||||
|
|||||||
@@ -129,8 +129,7 @@ export const actionGroup = register({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
contextItemLabel: "labels.group",
|
contextItemLabel: "labels.group",
|
||||||
contextItemPredicate: (elements, appState) =>
|
predicate: (elements, appState) => enableActionGroup(elements, appState),
|
||||||
enableActionGroup(elements, appState),
|
|
||||||
keyTest: (event) =>
|
keyTest: (event) =>
|
||||||
!event.shiftKey && event[KEYS.CTRL_OR_CMD] && event.key === KEYS.G,
|
!event.shiftKey && event[KEYS.CTRL_OR_CMD] && event.key === KEYS.G,
|
||||||
PanelComponent: ({ elements, appState, updateData }) => (
|
PanelComponent: ({ elements, appState, updateData }) => (
|
||||||
@@ -193,8 +192,7 @@ export const actionUngroup = register({
|
|||||||
event[KEYS.CTRL_OR_CMD] &&
|
event[KEYS.CTRL_OR_CMD] &&
|
||||||
event.key === KEYS.G.toUpperCase(),
|
event.key === KEYS.G.toUpperCase(),
|
||||||
contextItemLabel: "labels.ungroup",
|
contextItemLabel: "labels.ungroup",
|
||||||
contextItemPredicate: (elements, appState) =>
|
predicate: (elements, appState) => getSelectedGroupIds(appState).length > 0,
|
||||||
getSelectedGroupIds(appState).length > 0,
|
|
||||||
|
|
||||||
PanelComponent: ({ elements, appState, updateData }) => (
|
PanelComponent: ({ elements, appState, updateData }) => (
|
||||||
<ToolButton
|
<ToolButton
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export const actionToggleLinearEditor = register({
|
|||||||
trackEvent: {
|
trackEvent: {
|
||||||
category: "element",
|
category: "element",
|
||||||
},
|
},
|
||||||
contextItemPredicate: (elements, appState) => {
|
predicate: (elements, appState) => {
|
||||||
const selectedElements = getSelectedElements(elements, appState);
|
const selectedElements = getSelectedElements(elements, appState);
|
||||||
if (selectedElements.length === 1 && isLinearElement(selectedElements[0])) {
|
if (selectedElements.length === 1 && isLinearElement(selectedElements[0])) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import { HamburgerMenuIcon, HelpIcon, palette } from "../components/icons";
|
import { HamburgerMenuIcon, 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 { KEYS } from "../keys";
|
import { KEYS } from "../keys";
|
||||||
import { HelpButton } from "../components/HelpButton";
|
|
||||||
import MenuItem from "../components/MenuItem";
|
|
||||||
|
|
||||||
export const actionToggleCanvasMenu = register({
|
export const actionToggleCanvasMenu = register({
|
||||||
name: "toggleCanvasMenu",
|
name: "toggleCanvasMenu",
|
||||||
@@ -56,6 +54,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()) {
|
||||||
@@ -73,6 +72,7 @@ export const actionFullScreen = register({
|
|||||||
|
|
||||||
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.openDialog === "help") {
|
if (appState.openDialog === "help") {
|
||||||
@@ -86,17 +86,5 @@ export const actionShortcuts = register({
|
|||||||
commitToHistory: false,
|
commitToHistory: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
PanelComponent: ({ updateData, isInHamburgerMenu }) =>
|
|
||||||
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"];
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ 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 {
|
||||||
@@ -57,7 +58,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
isBoundToContainer,
|
isBoundToContainer,
|
||||||
isLinearElement,
|
isLinearElement,
|
||||||
isLinearElementType,
|
isUsingAdaptiveRadius,
|
||||||
} from "../element/typeChecks";
|
} from "../element/typeChecks";
|
||||||
import {
|
import {
|
||||||
Arrowhead,
|
Arrowhead,
|
||||||
@@ -72,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,
|
||||||
@@ -816,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) => {
|
||||||
@@ -845,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,
|
|
||||||
},
|
return (
|
||||||
{
|
<fieldset>
|
||||||
value: "round",
|
<legend>{t("labels.edges")}</legend>
|
||||||
text: t("labels.round"),
|
<ButtonIconSelect
|
||||||
icon: EdgeRoundIcon,
|
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({
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -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,
|
||||||
|
predicate: (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,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -41,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,
|
||||||
|
predicate: (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,
|
||||||
|
predicate: (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,
|
||||||
|
|||||||
+13
-12
@@ -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,11 +131,7 @@ export class ActionManager {
|
|||||||
/**
|
/**
|
||||||
* @param data additional data sent to the PanelComponent
|
* @param data additional data sent to the PanelComponent
|
||||||
*/
|
*/
|
||||||
renderAction = (
|
renderAction = (name: ActionName, data?: PanelComponentProps["data"]) => {
|
||||||
name: ActionName,
|
|
||||||
data?: PanelComponentProps["data"],
|
|
||||||
isInHamburgerMenu = false,
|
|
||||||
) => {
|
|
||||||
const canvasActions = this.app.props.UIOptions.canvasActions;
|
const canvasActions = this.app.props.UIOptions.canvasActions;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -174,11 +166,20 @@ export class ActionManager {
|
|||||||
updateData={updateData}
|
updateData={updateData}
|
||||||
appProps={this.app.props}
|
appProps={this.app.props}
|
||||||
data={data}
|
data={data}
|
||||||
isInHamburgerMenu={isInHamburgerMenu}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
isActionEnabled = (action: Action) => {
|
||||||
|
const elements = this.getElementsIncludingDeleted();
|
||||||
|
const appState = this.getAppState();
|
||||||
|
|
||||||
|
return (
|
||||||
|
!action.predicate ||
|
||||||
|
action.predicate(elements, appState, this.app.props, this.app)
|
||||||
|
);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ const shortcutMap: Record<ShortcutName, string[]> = {
|
|||||||
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"
|
||||||
@@ -124,9 +124,7 @@ export type PanelComponentProps = {
|
|||||||
|
|
||||||
export interface Action {
|
export interface Action {
|
||||||
name: ActionName;
|
name: ActionName;
|
||||||
PanelComponent?: React.FC<
|
PanelComponent?: React.FC<PanelComponentProps>;
|
||||||
PanelComponentProps & { isInHamburgerMenu: boolean }
|
|
||||||
>;
|
|
||||||
perform: ActionFn;
|
perform: ActionFn;
|
||||||
keyPriority?: number;
|
keyPriority?: number;
|
||||||
keyTest?: (
|
keyTest?: (
|
||||||
@@ -140,9 +138,11 @@ export interface Action {
|
|||||||
elements: readonly ExcalidrawElement[],
|
elements: readonly ExcalidrawElement[],
|
||||||
appState: Readonly<AppState>,
|
appState: Readonly<AppState>,
|
||||||
) => string);
|
) => string);
|
||||||
contextItemPredicate?: (
|
predicate?: (
|
||||||
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:
|
||||||
@@ -164,4 +164,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;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -28,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,
|
||||||
@@ -65,6 +64,7 @@ export const getDefaultAppState = (): Omit<
|
|||||||
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,
|
openSidebar: null,
|
||||||
@@ -120,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,
|
||||||
@@ -129,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 },
|
||||||
@@ -159,6 +158,7 @@ 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 },
|
openSidebar: { browser: true, export: false, server: false },
|
||||||
|
|||||||
+2
-2
@@ -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",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
+26
-14
@@ -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>) => {
|
||||||
|
|||||||
+12
-14
@@ -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,11 +25,12 @@ 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 clsx from "clsx";
|
||||||
import { actionToggleZenMode } from "../actions";
|
import { actionToggleZenMode } from "../actions";
|
||||||
import "./Actions.scss";
|
import "./Actions.scss";
|
||||||
import { Tooltip } from "./Tooltip";
|
import { Tooltip } from "./Tooltip";
|
||||||
|
import { shouldAllowVerticalAlign } from "../element/textElement";
|
||||||
|
|
||||||
export const SelectedShapeActions = ({
|
export const SelectedShapeActions = ({
|
||||||
appState,
|
appState,
|
||||||
@@ -109,9 +110,9 @@ export const SelectedShapeActions = ({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{(canChangeSharpness(appState.activeTool.type) ||
|
{(canChangeRoundness(appState.activeTool.type) ||
|
||||||
targetElements.some((element) => canChangeSharpness(element.type))) && (
|
targetElements.some((element) => canChangeRoundness(element.type))) && (
|
||||||
<>{renderAction("changeSharpness")}</>
|
<>{renderAction("changeRoundness")}</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{(hasText(appState.activeTool.type) ||
|
{(hasText(appState.activeTool.type) ||
|
||||||
@@ -125,10 +126,8 @@ export const SelectedShapeActions = ({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{targetElements.some(
|
{shouldAllowVerticalAlign(targetElements) &&
|
||||||
(element) =>
|
renderAction("changeVerticalAlign")}
|
||||||
hasBoundTextElement(element) || isBoundToContainer(element),
|
|
||||||
) && renderAction("changeVerticalAlign")}
|
|
||||||
{(canHaveArrowheads(appState.activeTool.type) ||
|
{(canHaveArrowheads(appState.activeTool.type) ||
|
||||||
targetElements.some((element) => canHaveArrowheads(element.type))) && (
|
targetElements.some((element) => canHaveArrowheads(element.type))) && (
|
||||||
<>{renderAction("changeArrowhead")}</>
|
<>{renderAction("changeArrowhead")}</>
|
||||||
@@ -218,13 +217,12 @@ export const ShapesSwitcher = ({
|
|||||||
appState: AppState;
|
appState: AppState;
|
||||||
}) => (
|
}) => (
|
||||||
<>
|
<>
|
||||||
{SHAPES.map(({ value, icon, key, fillable }, index) => {
|
{SHAPES.map(({ value, icon, key, numericKey, fillable }, index) => {
|
||||||
const numberKey = value === "eraser" ? 0 : index + 1;
|
|
||||||
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")} ${numberKey}`
|
? `${capitalizeString(letter)} ${t("helpDialog.or")} ${numericKey}`
|
||||||
: `${numberKey}`;
|
: `${numericKey}`;
|
||||||
return (
|
return (
|
||||||
<ToolButton
|
<ToolButton
|
||||||
className={clsx("Shape", { fillable })}
|
className={clsx("Shape", { fillable })}
|
||||||
@@ -234,7 +232,7 @@ export const ShapesSwitcher = ({
|
|||||||
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={`${numberKey}`}
|
keyBindingLabel={numericKey}
|
||||||
aria-label={capitalizeString(label)}
|
aria-label={capitalizeString(label)}
|
||||||
aria-keyshortcuts={shortcut}
|
aria-keyshortcuts={shortcut}
|
||||||
data-testid={`toolbar-${value}`}
|
data-testid={`toolbar-${value}`}
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
// TODO barnabasmolnar/editor-redesign
|
|
||||||
// this icon is not great
|
|
||||||
import { getShortcutFromShortcutName } from "../actions/shortcuts";
|
|
||||||
import { save } from "../components/icons";
|
|
||||||
import { t } from "../i18n";
|
|
||||||
|
|
||||||
import "./ActiveFile.scss";
|
|
||||||
import MenuItem from "./MenuItem";
|
|
||||||
|
|
||||||
type ActiveFileProps = {
|
|
||||||
fileName?: string;
|
|
||||||
onSave: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const ActiveFile = ({ fileName, onSave }: ActiveFileProps) => (
|
|
||||||
<MenuItem
|
|
||||||
label={`${t("buttons.save")}`}
|
|
||||||
shortcut={getShortcutFromShortcutName("saveScene")}
|
|
||||||
dataTestId="save-button"
|
|
||||||
onClick={onSave}
|
|
||||||
icon={save}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
+557
-453
File diff suppressed because it is too large
Load Diff
@@ -4,8 +4,8 @@
|
|||||||
.Avatar {
|
.Avatar {
|
||||||
width: 1.25rem;
|
width: 1.25rem;
|
||||||
height: 1.25rem;
|
height: 1.25rem;
|
||||||
|
position: relative;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
outline: 2px solid var(--avatar-border-color);
|
|
||||||
outline-offset: 2px;
|
outline-offset: 2px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -21,5 +21,16 @@
|
|||||||
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%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
@import "../css/theme";
|
||||||
|
|
||||||
|
.excalidraw {
|
||||||
|
.excalidraw-button {
|
||||||
|
@include outlineButtonStyles;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import "./Button.scss";
|
||||||
|
|
||||||
|
interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
|
||||||
|
type?: "button" | "submit" | "reset";
|
||||||
|
onSelect: () => any;
|
||||||
|
children: React.ReactNode;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A generic button component that follows Excalidraw's design system.
|
||||||
|
* Style can be customised using `className` or `style` prop.
|
||||||
|
* Accepts all props that a regular `button` element accepts.
|
||||||
|
*/
|
||||||
|
export const Button = ({
|
||||||
|
type = "button",
|
||||||
|
onSelect,
|
||||||
|
children,
|
||||||
|
className = "",
|
||||||
|
...rest
|
||||||
|
}: ButtonProps) => {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
onClick={(event) => {
|
||||||
|
onSelect();
|
||||||
|
rest.onClick?.(event);
|
||||||
|
}}
|
||||||
|
type={type}
|
||||||
|
className={`excalidraw-button ${className}`}
|
||||||
|
{...rest}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import { useState } from "react";
|
|
||||||
import { t } from "../i18n";
|
|
||||||
import { TrashIcon } from "./icons";
|
|
||||||
|
|
||||||
import ConfirmDialog from "./ConfirmDialog";
|
|
||||||
import MenuItem from "./MenuItem";
|
|
||||||
|
|
||||||
const ClearCanvas = ({ onConfirm }: { onConfirm: () => void }) => {
|
|
||||||
const [showDialog, setShowDialog] = useState(false);
|
|
||||||
const toggleDialog = () => {
|
|
||||||
setShowDialog(!showDialog);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<MenuItem
|
|
||||||
label={t("buttons.clearReset")}
|
|
||||||
icon={TrashIcon}
|
|
||||||
onClick={toggleDialog}
|
|
||||||
dataTestId="clear-canvas-button"
|
|
||||||
/>
|
|
||||||
|
|
||||||
{showDialog && (
|
|
||||||
<ConfirmDialog
|
|
||||||
onConfirm={() => {
|
|
||||||
onConfirm();
|
|
||||||
toggleDialog();
|
|
||||||
}}
|
|
||||||
onCancel={toggleDialog}
|
|
||||||
title={t("clearCanvasDialog.title")}
|
|
||||||
>
|
|
||||||
<p className="clear-canvas__content"> {t("alerts.clearReset")}</p>
|
|
||||||
</ConfirmDialog>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ClearCanvas;
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
import { t } from "../i18n";
|
|
||||||
import { UsersIcon } from "./icons";
|
|
||||||
|
|
||||||
import "./CollabButton.scss";
|
|
||||||
import MenuItem from "./MenuItem";
|
|
||||||
import clsx from "clsx";
|
|
||||||
|
|
||||||
const CollabButton = ({
|
|
||||||
isCollaborating,
|
|
||||||
collaboratorCount,
|
|
||||||
onClick,
|
|
||||||
isInHamburgerMenu = true,
|
|
||||||
}: {
|
|
||||||
isCollaborating: boolean;
|
|
||||||
collaboratorCount: number;
|
|
||||||
onClick: () => void;
|
|
||||||
isInHamburgerMenu?: boolean;
|
|
||||||
}) => {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{isInHamburgerMenu ? (
|
|
||||||
<MenuItem
|
|
||||||
label={t("labels.liveCollaboration")}
|
|
||||||
dataTestId="collab-button"
|
|
||||||
icon={UsersIcon}
|
|
||||||
onClick={onClick}
|
|
||||||
isCollaborating={isCollaborating}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<button
|
|
||||||
className={clsx("collab-button", { active: isCollaborating })}
|
|
||||||
type="button"
|
|
||||||
onClick={onClick}
|
|
||||||
style={{ position: "relative" }}
|
|
||||||
title={t("labels.liveCollaboration")}
|
|
||||||
>
|
|
||||||
{UsersIcon}
|
|
||||||
{collaboratorCount > 0 && (
|
|
||||||
<div className="CollabButton-collaborators">
|
|
||||||
{collaboratorCount}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default CollabButton;
|
|
||||||
@@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import { Dialog, DialogProps } from "./Dialog";
|
|||||||
|
|
||||||
import "./ConfirmDialog.scss";
|
import "./ConfirmDialog.scss";
|
||||||
import DialogActionButton from "./DialogActionButton";
|
import DialogActionButton from "./DialogActionButton";
|
||||||
import { isMenuOpenAtom } from "./App";
|
|
||||||
import { isDropdownOpenAtom } from "./App";
|
|
||||||
import { useSetAtom } from "jotai";
|
import { useSetAtom } from "jotai";
|
||||||
|
import { isLibraryMenuOpenAtom } from "./LibraryMenuHeaderContent";
|
||||||
|
import { useExcalidrawSetAppState } from "./App";
|
||||||
|
|
||||||
interface Props extends Omit<DialogProps, "onCloseRequest"> {
|
interface Props extends Omit<DialogProps, "onCloseRequest"> {
|
||||||
onConfirm: () => void;
|
onConfirm: () => void;
|
||||||
@@ -23,9 +23,8 @@ const ConfirmDialog = (props: Props) => {
|
|||||||
className = "",
|
className = "",
|
||||||
...rest
|
...rest
|
||||||
} = props;
|
} = props;
|
||||||
|
const setAppState = useExcalidrawSetAppState();
|
||||||
const setIsMenuOpen = useSetAtom(isMenuOpenAtom);
|
const setIsLibraryMenuOpen = useSetAtom(isLibraryMenuOpenAtom);
|
||||||
const setIsDropdownOpen = useSetAtom(isDropdownOpenAtom);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
@@ -39,16 +38,16 @@ const ConfirmDialog = (props: Props) => {
|
|||||||
<DialogActionButton
|
<DialogActionButton
|
||||||
label={cancelText}
|
label={cancelText}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setIsMenuOpen(false);
|
setAppState({ openMenu: null });
|
||||||
setIsDropdownOpen(false);
|
setIsLibraryMenuOpen(false);
|
||||||
onCancel();
|
onCancel();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<DialogActionButton
|
<DialogActionButton
|
||||||
label={confirmText}
|
label={confirmText}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setIsMenuOpen(false);
|
setAppState({ openMenu: null });
|
||||||
setIsDropdownOpen(false);
|
setIsLibraryMenuOpen(false);
|
||||||
onConfirm();
|
onConfirm();
|
||||||
}}
|
}}
|
||||||
actionType="danger"
|
actionType="danger"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
color: var(--popup-text-color);
|
color: var(--popup-text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.context-menu-option {
|
.context-menu-item {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-width: 9.5rem;
|
min-width: 9.5rem;
|
||||||
@@ -43,16 +43,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.dangerous {
|
&.dangerous {
|
||||||
.context-menu-option__label {
|
.context-menu-item__label {
|
||||||
color: $oc-red-7;
|
color: $oc-red-7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.context-menu-option__label {
|
.context-menu-item__label {
|
||||||
justify-self: start;
|
justify-self: start;
|
||||||
margin-inline-end: 20px;
|
margin-inline-end: 20px;
|
||||||
}
|
}
|
||||||
.context-menu-option__shortcut {
|
.context-menu-item__shortcut {
|
||||||
justify-self: end;
|
justify-self: end;
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
@@ -60,37 +60,37 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.context-menu-option:hover {
|
.context-menu-item:hover {
|
||||||
color: var(--popup-bg-color);
|
color: var(--popup-bg-color);
|
||||||
background-color: var(--select-highlight-color);
|
background-color: var(--select-highlight-color);
|
||||||
|
|
||||||
&.dangerous {
|
&.dangerous {
|
||||||
.context-menu-option__label {
|
.context-menu-item__label {
|
||||||
color: var(--popup-bg-color);
|
color: var(--popup-bg-color);
|
||||||
}
|
}
|
||||||
background-color: $oc-red-6;
|
background-color: $oc-red-6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.context-menu-option:focus {
|
.context-menu-item:focus {
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@include isMobile {
|
@include isMobile {
|
||||||
.context-menu-option {
|
.context-menu-item {
|
||||||
display: block;
|
display: block;
|
||||||
|
|
||||||
.context-menu-option__label {
|
.context-menu-item__label {
|
||||||
margin-inline-end: 0;
|
margin-inline-end: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.context-menu-option__shortcut {
|
.context-menu-item__shortcut {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.context-menu-option-separator {
|
.context-menu-item-separator {
|
||||||
border: none;
|
border: none;
|
||||||
border-top: 1px solid $oc-gray-5;
|
border-top: 1px solid $oc-gray-5;
|
||||||
}
|
}
|
||||||
|
|||||||
+102
-127
@@ -1,4 +1,3 @@
|
|||||||
import { render, unmountComponentAtNode } from "react-dom";
|
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { Popover } from "./Popover";
|
import { Popover } from "./Popover";
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
@@ -10,140 +9,116 @@ import {
|
|||||||
} from "../actions/shortcuts";
|
} from "../actions/shortcuts";
|
||||||
import { Action } from "../actions/types";
|
import { Action } from "../actions/types";
|
||||||
import { ActionManager } from "../actions/manager";
|
import { ActionManager } from "../actions/manager";
|
||||||
import { AppState } from "../types";
|
import {
|
||||||
import { NonDeletedExcalidrawElement } from "../element/types";
|
useExcalidrawAppState,
|
||||||
|
useExcalidrawElements,
|
||||||
|
useExcalidrawSetAppState,
|
||||||
|
} from "./App";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
export type ContextMenuOption = "separator" | Action;
|
export type ContextMenuItem = typeof CONTEXT_MENU_SEPARATOR | Action;
|
||||||
|
|
||||||
|
export type ContextMenuItems = (ContextMenuItem | false | null | undefined)[];
|
||||||
|
|
||||||
type ContextMenuProps = {
|
type ContextMenuProps = {
|
||||||
options: ContextMenuOption[];
|
actionManager: ActionManager;
|
||||||
onCloseRequest?(): void;
|
items: ContextMenuItems;
|
||||||
top: number;
|
top: number;
|
||||||
left: number;
|
left: number;
|
||||||
actionManager: ActionManager;
|
|
||||||
appState: Readonly<AppState>;
|
|
||||||
elements: readonly NonDeletedExcalidrawElement[];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const ContextMenu = ({
|
export const CONTEXT_MENU_SEPARATOR = "separator";
|
||||||
options,
|
|
||||||
onCloseRequest,
|
|
||||||
top,
|
|
||||||
left,
|
|
||||||
actionManager,
|
|
||||||
appState,
|
|
||||||
elements,
|
|
||||||
}: ContextMenuProps) => {
|
|
||||||
return (
|
|
||||||
<Popover
|
|
||||||
onCloseRequest={onCloseRequest}
|
|
||||||
top={top}
|
|
||||||
left={left}
|
|
||||||
fitInViewport={true}
|
|
||||||
offsetLeft={appState.offsetLeft}
|
|
||||||
offsetTop={appState.offsetTop}
|
|
||||||
viewportWidth={appState.width}
|
|
||||||
viewportHeight={appState.height}
|
|
||||||
>
|
|
||||||
<ul
|
|
||||||
className="context-menu"
|
|
||||||
onContextMenu={(event) => event.preventDefault()}
|
|
||||||
>
|
|
||||||
{options.map((option, idx) => {
|
|
||||||
if (option === "separator") {
|
|
||||||
return <hr key={idx} className="context-menu-option-separator" />;
|
|
||||||
}
|
|
||||||
|
|
||||||
const actionName = option.name;
|
export const ContextMenu = React.memo(
|
||||||
let label = "";
|
({ actionManager, items, top, left }: ContextMenuProps) => {
|
||||||
if (option.contextItemLabel) {
|
const appState = useExcalidrawAppState();
|
||||||
if (typeof option.contextItemLabel === "function") {
|
const setAppState = useExcalidrawSetAppState();
|
||||||
label = t(option.contextItemLabel(elements, appState));
|
const elements = useExcalidrawElements();
|
||||||
} else {
|
|
||||||
label = t(option.contextItemLabel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<li key={idx} data-testid={actionName} onClick={onCloseRequest}>
|
|
||||||
<button
|
|
||||||
className={clsx("context-menu-option", {
|
|
||||||
dangerous: actionName === "deleteSelectedElements",
|
|
||||||
checkmark: option.checked?.(appState),
|
|
||||||
})}
|
|
||||||
onClick={() =>
|
|
||||||
actionManager.executeAction(option, "contextMenu")
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<div className="context-menu-option__label">{label}</div>
|
|
||||||
<kbd className="context-menu-option__shortcut">
|
|
||||||
{actionName
|
|
||||||
? getShortcutFromShortcutName(actionName as ShortcutName)
|
|
||||||
: ""}
|
|
||||||
</kbd>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</ul>
|
|
||||||
</Popover>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const contextMenuNodeByContainer = new WeakMap<HTMLElement, HTMLDivElement>();
|
const filteredItems = items.reduce((acc: ContextMenuItem[], item) => {
|
||||||
|
if (
|
||||||
const getContextMenuNode = (container: HTMLElement): HTMLDivElement => {
|
item &&
|
||||||
let contextMenuNode = contextMenuNodeByContainer.get(container);
|
(item === CONTEXT_MENU_SEPARATOR ||
|
||||||
if (contextMenuNode) {
|
!item.predicate ||
|
||||||
return contextMenuNode;
|
item.predicate(
|
||||||
}
|
elements,
|
||||||
contextMenuNode = document.createElement("div");
|
appState,
|
||||||
container
|
actionManager.app.props,
|
||||||
.querySelector(".excalidraw-contextMenuContainer")!
|
actionManager.app,
|
||||||
.appendChild(contextMenuNode);
|
))
|
||||||
contextMenuNodeByContainer.set(container, contextMenuNode);
|
) {
|
||||||
return contextMenuNode;
|
acc.push(item);
|
||||||
};
|
|
||||||
|
|
||||||
type ContextMenuParams = {
|
|
||||||
options: (ContextMenuOption | false | null | undefined)[];
|
|
||||||
top: ContextMenuProps["top"];
|
|
||||||
left: ContextMenuProps["left"];
|
|
||||||
actionManager: ContextMenuProps["actionManager"];
|
|
||||||
appState: Readonly<AppState>;
|
|
||||||
container: HTMLElement;
|
|
||||||
elements: readonly NonDeletedExcalidrawElement[];
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleClose = (container: HTMLElement) => {
|
|
||||||
const contextMenuNode = contextMenuNodeByContainer.get(container);
|
|
||||||
if (contextMenuNode) {
|
|
||||||
unmountComponentAtNode(contextMenuNode);
|
|
||||||
contextMenuNode.remove();
|
|
||||||
contextMenuNodeByContainer.delete(container);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
push(params: ContextMenuParams) {
|
|
||||||
const options = Array.of<ContextMenuOption>();
|
|
||||||
params.options.forEach((option) => {
|
|
||||||
if (option) {
|
|
||||||
options.push(option);
|
|
||||||
}
|
}
|
||||||
});
|
return acc;
|
||||||
if (options.length) {
|
}, []);
|
||||||
render(
|
|
||||||
<ContextMenu
|
return (
|
||||||
top={params.top}
|
<Popover
|
||||||
left={params.left}
|
onCloseRequest={() => setAppState({ contextMenu: null })}
|
||||||
options={options}
|
top={top}
|
||||||
onCloseRequest={() => handleClose(params.container)}
|
left={left}
|
||||||
actionManager={params.actionManager}
|
fitInViewport={true}
|
||||||
appState={params.appState}
|
offsetLeft={appState.offsetLeft}
|
||||||
elements={params.elements}
|
offsetTop={appState.offsetTop}
|
||||||
/>,
|
viewportWidth={appState.width}
|
||||||
getContextMenuNode(params.container),
|
viewportHeight={appState.height}
|
||||||
);
|
>
|
||||||
}
|
<ul
|
||||||
|
className="context-menu"
|
||||||
|
onContextMenu={(event) => event.preventDefault()}
|
||||||
|
>
|
||||||
|
{filteredItems.map((item, idx) => {
|
||||||
|
if (item === CONTEXT_MENU_SEPARATOR) {
|
||||||
|
if (
|
||||||
|
!filteredItems[idx - 1] ||
|
||||||
|
filteredItems[idx - 1] === CONTEXT_MENU_SEPARATOR
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return <hr key={idx} className="context-menu-item-separator" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
const actionName = item.name;
|
||||||
|
let label = "";
|
||||||
|
if (item.contextItemLabel) {
|
||||||
|
if (typeof item.contextItemLabel === "function") {
|
||||||
|
label = t(item.contextItemLabel(elements, appState));
|
||||||
|
} else {
|
||||||
|
label = t(item.contextItemLabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<li
|
||||||
|
key={idx}
|
||||||
|
data-testid={actionName}
|
||||||
|
onClick={() => {
|
||||||
|
// we need update state before executing the action in case
|
||||||
|
// the action uses the appState it's being passed (that still
|
||||||
|
// contains a defined contextMenu) to return the next state.
|
||||||
|
setAppState({ contextMenu: null }, () => {
|
||||||
|
actionManager.executeAction(item, "contextMenu");
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className={clsx("context-menu-item", {
|
||||||
|
dangerous: actionName === "deleteSelectedElements",
|
||||||
|
checkmark: item.checked?.(appState),
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<div className="context-menu-item__label">{label}</div>
|
||||||
|
<kbd className="context-menu-item__shortcut">
|
||||||
|
{actionName
|
||||||
|
? getShortcutFromShortcutName(actionName as ShortcutName)
|
||||||
|
: ""}
|
||||||
|
</kbd>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
</Popover>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
};
|
);
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import clsx from "clsx";
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useCallbackRefState } from "../hooks/useCallbackRefState";
|
import { useCallbackRefState } from "../hooks/useCallbackRefState";
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { useExcalidrawContainer, useDevice } from "../components/App";
|
import {
|
||||||
|
useExcalidrawContainer,
|
||||||
|
useDevice,
|
||||||
|
useExcalidrawSetAppState,
|
||||||
|
} from "../components/App";
|
||||||
import { KEYS } from "../keys";
|
import { KEYS } from "../keys";
|
||||||
import "./Dialog.scss";
|
import "./Dialog.scss";
|
||||||
import { back, CloseIcon } from "./icons";
|
import { back, CloseIcon } from "./icons";
|
||||||
@@ -10,8 +14,8 @@ import { Island } from "./Island";
|
|||||||
import { Modal } from "./Modal";
|
import { Modal } from "./Modal";
|
||||||
import { AppState } from "../types";
|
import { AppState } from "../types";
|
||||||
import { queryFocusableElements } from "../utils";
|
import { queryFocusableElements } from "../utils";
|
||||||
import { isMenuOpenAtom, isDropdownOpenAtom } from "./App";
|
|
||||||
import { useSetAtom } from "jotai";
|
import { useSetAtom } from "jotai";
|
||||||
|
import { isLibraryMenuOpenAtom } from "./LibraryMenuHeaderContent";
|
||||||
|
|
||||||
export interface DialogProps {
|
export interface DialogProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
@@ -67,12 +71,12 @@ export const Dialog = (props: DialogProps) => {
|
|||||||
return () => islandNode.removeEventListener("keydown", handleKeyDown);
|
return () => islandNode.removeEventListener("keydown", handleKeyDown);
|
||||||
}, [islandNode, props.autofocus]);
|
}, [islandNode, props.autofocus]);
|
||||||
|
|
||||||
const setIsMenuOpen = useSetAtom(isMenuOpenAtom);
|
const setAppState = useExcalidrawSetAppState();
|
||||||
const setIsDropdownOpen = useSetAtom(isDropdownOpenAtom);
|
const setIsLibraryMenuOpen = useSetAtom(isLibraryMenuOpenAtom);
|
||||||
|
|
||||||
const onClose = () => {
|
const onClose = () => {
|
||||||
setIsMenuOpen(false);
|
setAppState({ openMenu: null });
|
||||||
setIsDropdownOpen(false);
|
setIsLibraryMenuOpen(false);
|
||||||
(lastActiveElement as HTMLElement).focus();
|
(lastActiveElement as HTMLElement).focus();
|
||||||
props.onCloseRequest();
|
props.onCloseRequest();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@import "../css/variables.module";
|
||||||
|
|
||||||
.excalidraw {
|
.excalidraw {
|
||||||
.FixedSideContainer {
|
.FixedSideContainer {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -9,10 +11,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.FixedSideContainer_side_top {
|
.FixedSideContainer_side_top {
|
||||||
left: 1rem;
|
left: var(--editor-container-padding);
|
||||||
top: 1rem;
|
top: var(--editor-container-padding);
|
||||||
right: 1rem;
|
right: var(--editor-container-padding);
|
||||||
bottom: 1rem;
|
bottom: var(--editor-container-padding);
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { isDarwin, isWindows } from "../keys";
|
import { isDarwin, isWindows, KEYS } from "../keys";
|
||||||
import { Dialog } from "./Dialog";
|
import { Dialog } from "./Dialog";
|
||||||
import { getShortcutKey } from "../utils";
|
import { getShortcutKey } from "../utils";
|
||||||
import "./HelpDialog.scss";
|
import "./HelpDialog.scss";
|
||||||
@@ -118,26 +118,49 @@ export const HelpDialog = ({ onClose }: { onClose?: () => void }) => {
|
|||||||
className="HelpDialog__island--tools"
|
className="HelpDialog__island--tools"
|
||||||
caption={t("helpDialog.tools")}
|
caption={t("helpDialog.tools")}
|
||||||
>
|
>
|
||||||
<Shortcut label={t("toolBar.selection")} shortcuts={["V", "1"]} />
|
<Shortcut
|
||||||
<Shortcut label={t("toolBar.rectangle")} shortcuts={["R", "2"]} />
|
label={t("toolBar.selection")}
|
||||||
<Shortcut label={t("toolBar.diamond")} shortcuts={["D", "3"]} />
|
shortcuts={[KEYS.V, KEYS["1"]]}
|
||||||
<Shortcut label={t("toolBar.ellipse")} shortcuts={["O", "4"]} />
|
/>
|
||||||
<Shortcut label={t("toolBar.arrow")} shortcuts={["A", "5"]} />
|
<Shortcut
|
||||||
<Shortcut label={t("toolBar.line")} shortcuts={["P", "6"]} />
|
label={t("toolBar.rectangle")}
|
||||||
|
shortcuts={[KEYS.R, KEYS["2"]]}
|
||||||
|
/>
|
||||||
|
<Shortcut
|
||||||
|
label={t("toolBar.diamond")}
|
||||||
|
shortcuts={[KEYS.D, KEYS["3"]]}
|
||||||
|
/>
|
||||||
|
<Shortcut
|
||||||
|
label={t("toolBar.ellipse")}
|
||||||
|
shortcuts={[KEYS.O, KEYS["4"]]}
|
||||||
|
/>
|
||||||
|
<Shortcut
|
||||||
|
label={t("toolBar.arrow")}
|
||||||
|
shortcuts={[KEYS.A, KEYS["5"]]}
|
||||||
|
/>
|
||||||
|
<Shortcut
|
||||||
|
label={t("toolBar.line")}
|
||||||
|
shortcuts={[KEYS.L, KEYS["6"]]}
|
||||||
|
/>
|
||||||
<Shortcut
|
<Shortcut
|
||||||
label={t("toolBar.freedraw")}
|
label={t("toolBar.freedraw")}
|
||||||
shortcuts={["Shift + P", "X", "7"]}
|
shortcuts={[KEYS.P, KEYS["7"]]}
|
||||||
/>
|
/>
|
||||||
<Shortcut label={t("toolBar.text")} shortcuts={["T", "8"]} />
|
<Shortcut
|
||||||
<Shortcut label={t("toolBar.image")} shortcuts={["9"]} />
|
label={t("toolBar.text")}
|
||||||
<Shortcut label={t("toolBar.library")} shortcuts={["0"]} />
|
shortcuts={[KEYS.T, KEYS["8"]]}
|
||||||
|
/>
|
||||||
|
<Shortcut label={t("toolBar.image")} shortcuts={[KEYS["9"]]} />
|
||||||
<Shortcut
|
<Shortcut
|
||||||
label={t("toolBar.eraser")}
|
label={t("toolBar.eraser")}
|
||||||
shortcuts={[getShortcutKey("E")]}
|
shortcuts={[KEYS.E, KEYS["0"]]}
|
||||||
/>
|
/>
|
||||||
<Shortcut
|
<Shortcut
|
||||||
label={t("helpDialog.editSelectedShape")}
|
label={t("helpDialog.editSelectedShape")}
|
||||||
shortcuts={[getShortcutKey("Enter"), t("helpDialog.doubleClick")]}
|
shortcuts={[
|
||||||
|
getShortcutKey("CtrlOrCmd+Enter"),
|
||||||
|
getShortcutKey(`CtrlOrCmd + ${t("helpDialog.doubleClick")}`),
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
<Shortcut
|
<Shortcut
|
||||||
label={t("helpDialog.textNewLine")}
|
label={t("helpDialog.textNewLine")}
|
||||||
@@ -173,7 +196,7 @@ export const HelpDialog = ({ onClose }: { onClose?: () => void }) => {
|
|||||||
]}
|
]}
|
||||||
isOr={false}
|
isOr={false}
|
||||||
/>
|
/>
|
||||||
<Shortcut label={t("toolBar.lock")} shortcuts={["Q"]} />
|
<Shortcut label={t("toolBar.lock")} shortcuts={[KEYS.Q]} />
|
||||||
<Shortcut
|
<Shortcut
|
||||||
label={t("helpDialog.preventBinding")}
|
label={t("helpDialog.preventBinding")}
|
||||||
shortcuts={[getShortcutKey("CtrlOrCmd")]}
|
shortcuts={[getShortcutKey("CtrlOrCmd")]}
|
||||||
@@ -207,6 +230,14 @@ export const HelpDialog = ({ onClose }: { onClose?: () => void }) => {
|
|||||||
label={t("helpDialog.zoomToSelection")}
|
label={t("helpDialog.zoomToSelection")}
|
||||||
shortcuts={["Shift+2"]}
|
shortcuts={["Shift+2"]}
|
||||||
/>
|
/>
|
||||||
|
<Shortcut
|
||||||
|
label={t("helpDialog.movePageUpDown")}
|
||||||
|
shortcuts={["PgUp/PgDn"]}
|
||||||
|
/>
|
||||||
|
<Shortcut
|
||||||
|
label={t("helpDialog.movePageLeftRight")}
|
||||||
|
shortcuts={["Shift+PgUp/PgDn"]}
|
||||||
|
/>
|
||||||
<Shortcut label={t("buttons.fullScreen")} shortcuts={["F"]} />
|
<Shortcut label={t("buttons.fullScreen")} shortcuts={["F"]} />
|
||||||
<Shortcut
|
<Shortcut
|
||||||
label={t("buttons.zenMode")}
|
label={t("buttons.zenMode")}
|
||||||
@@ -269,6 +300,10 @@ export const HelpDialog = ({ onClose }: { onClose?: () => void }) => {
|
|||||||
label={t("labels.paste")}
|
label={t("labels.paste")}
|
||||||
shortcuts={[getShortcutKey("CtrlOrCmd+V")]}
|
shortcuts={[getShortcutKey("CtrlOrCmd+V")]}
|
||||||
/>
|
/>
|
||||||
|
<Shortcut
|
||||||
|
label={t("labels.pasteAsPlaintext")}
|
||||||
|
shortcuts={[getShortcutKey("CtrlOrCmd+Shift+V")]}
|
||||||
|
/>
|
||||||
<Shortcut
|
<Shortcut
|
||||||
label={t("labels.copyAsPng")}
|
label={t("labels.copyAsPng")}
|
||||||
shortcuts={[getShortcutKey("Shift+Alt+C")]}
|
shortcuts={[getShortcutKey("Shift+Alt+C")]}
|
||||||
@@ -283,7 +318,7 @@ export const HelpDialog = ({ onClose }: { onClose?: () => void }) => {
|
|||||||
/>
|
/>
|
||||||
<Shortcut
|
<Shortcut
|
||||||
label={t("labels.delete")}
|
label={t("labels.delete")}
|
||||||
shortcuts={[getShortcutKey("Del")]}
|
shortcuts={[getShortcutKey("Delete")]}
|
||||||
/>
|
/>
|
||||||
<Shortcut
|
<Shortcut
|
||||||
label={t("labels.sendToBack")}
|
label={t("labels.sendToBack")}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, { useEffect, useRef, useState } from "react";
|
||||||
import { render, unmountComponentAtNode } from "react-dom";
|
|
||||||
import { probablySupportsClipboardBlob } from "../clipboard";
|
import { probablySupportsClipboardBlob } from "../clipboard";
|
||||||
import { canvasToBlob } from "../data/blob";
|
import { canvasToBlob } from "../data/blob";
|
||||||
import { NonDeletedExcalidrawElement } from "../element/types";
|
import { NonDeletedExcalidrawElement } from "../element/types";
|
||||||
import { CanvasError } from "../errors";
|
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import { getSelectedElements, isSomeElementSelected } from "../scene";
|
import { getSelectedElements, isSomeElementSelected } from "../scene";
|
||||||
import { exportToCanvas } from "../scene/export";
|
import { exportToCanvas } from "../scene/export";
|
||||||
@@ -33,19 +31,6 @@ export const ErrorCanvasPreview = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderPreview = (
|
|
||||||
content: HTMLCanvasElement | Error,
|
|
||||||
previewNode: HTMLDivElement,
|
|
||||||
) => {
|
|
||||||
unmountComponentAtNode(previewNode);
|
|
||||||
previewNode.innerHTML = "";
|
|
||||||
if (content instanceof HTMLCanvasElement) {
|
|
||||||
previewNode.appendChild(content);
|
|
||||||
} else {
|
|
||||||
render(<ErrorCanvasPreview />, previewNode);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export type ExportCB = (
|
export type ExportCB = (
|
||||||
elements: readonly NonDeletedExcalidrawElement[],
|
elements: readonly NonDeletedExcalidrawElement[],
|
||||||
scale?: number,
|
scale?: number,
|
||||||
@@ -99,6 +84,7 @@ const ImageExportModal = ({
|
|||||||
const [exportSelected, setExportSelected] = useState(someElementIsSelected);
|
const [exportSelected, setExportSelected] = useState(someElementIsSelected);
|
||||||
const previewRef = useRef<HTMLDivElement>(null);
|
const previewRef = useRef<HTMLDivElement>(null);
|
||||||
const { exportBackground, viewBackgroundColor } = appState;
|
const { exportBackground, viewBackgroundColor } = appState;
|
||||||
|
const [renderError, setRenderError] = useState<Error | null>(null);
|
||||||
|
|
||||||
const exportedElements = exportSelected
|
const exportedElements = exportSelected
|
||||||
? getSelectedElements(elements, appState, true)
|
? getSelectedElements(elements, appState, true)
|
||||||
@@ -119,15 +105,16 @@ const ImageExportModal = ({
|
|||||||
exportPadding,
|
exportPadding,
|
||||||
})
|
})
|
||||||
.then((canvas) => {
|
.then((canvas) => {
|
||||||
|
setRenderError(null);
|
||||||
// if converting to blob fails, there's some problem that will
|
// if converting to blob fails, there's some problem that will
|
||||||
// likely prevent preview and export (e.g. canvas too big)
|
// likely prevent preview and export (e.g. canvas too big)
|
||||||
return canvasToBlob(canvas).then(() => {
|
return canvasToBlob(canvas).then(() => {
|
||||||
renderPreview(canvas, previewNode);
|
previewNode.replaceChildren(canvas);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
renderPreview(new CanvasError(), previewNode);
|
setRenderError(error);
|
||||||
});
|
});
|
||||||
}, [
|
}, [
|
||||||
appState,
|
appState,
|
||||||
@@ -140,7 +127,9 @@ const ImageExportModal = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ExportDialog">
|
<div className="ExportDialog">
|
||||||
<div className="ExportDialog__preview" ref={previewRef} />
|
<div className="ExportDialog__preview" ref={previewRef}>
|
||||||
|
{renderError && <ErrorCanvasPreview />}
|
||||||
|
</div>
|
||||||
{supportsContextFilters &&
|
{supportsContextFilters &&
|
||||||
actionManager.renderAction("exportWithDarkMode")}
|
actionManager.renderAction("exportWithDarkMode")}
|
||||||
<div style={{ display: "grid", gridTemplateColumns: "1fr" }}>
|
<div style={{ display: "grid", gridTemplateColumns: "1fr" }}>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import React, { useState } from "react";
|
import React from "react";
|
||||||
import { NonDeletedExcalidrawElement } from "../element/types";
|
import { NonDeletedExcalidrawElement } from "../element/types";
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
|
|
||||||
import { AppState, ExportOpts, BinaryFiles } from "../types";
|
import { AppState, ExportOpts, BinaryFiles } from "../types";
|
||||||
import { Dialog } from "./Dialog";
|
import { Dialog } from "./Dialog";
|
||||||
import { ExportIcon, exportToFileIcon, LinkIcon } from "./icons";
|
import { exportToFileIcon, LinkIcon } from "./icons";
|
||||||
import { ToolButton } from "./ToolButton";
|
import { ToolButton } from "./ToolButton";
|
||||||
import { actionSaveFileToDisk } from "../actions/actionExport";
|
import { actionSaveFileToDisk } from "../actions/actionExport";
|
||||||
import { Card } from "./Card";
|
import { Card } from "./Card";
|
||||||
@@ -14,7 +14,6 @@ import { nativeFileSystemSupported } from "../data/filesystem";
|
|||||||
import { trackEvent } from "../analytics";
|
import { trackEvent } from "../analytics";
|
||||||
import { ActionManager } from "../actions/manager";
|
import { ActionManager } from "../actions/manager";
|
||||||
import { getFrame } from "../utils";
|
import { getFrame } from "../utils";
|
||||||
import MenuItem from "./MenuItem";
|
|
||||||
|
|
||||||
export type ExportCB = (
|
export type ExportCB = (
|
||||||
elements: readonly NonDeletedExcalidrawElement[],
|
elements: readonly NonDeletedExcalidrawElement[],
|
||||||
@@ -94,6 +93,7 @@ export const JSONExportDialog = ({
|
|||||||
actionManager,
|
actionManager,
|
||||||
exportOpts,
|
exportOpts,
|
||||||
canvas,
|
canvas,
|
||||||
|
setAppState,
|
||||||
}: {
|
}: {
|
||||||
elements: readonly NonDeletedExcalidrawElement[];
|
elements: readonly NonDeletedExcalidrawElement[];
|
||||||
appState: AppState;
|
appState: AppState;
|
||||||
@@ -101,24 +101,15 @@ export const JSONExportDialog = ({
|
|||||||
actionManager: ActionManager;
|
actionManager: ActionManager;
|
||||||
exportOpts: ExportOpts;
|
exportOpts: ExportOpts;
|
||||||
canvas: HTMLCanvasElement | null;
|
canvas: HTMLCanvasElement | null;
|
||||||
|
setAppState: React.Component<any, AppState>["setState"];
|
||||||
}) => {
|
}) => {
|
||||||
const [modalIsShown, setModalIsShown] = useState(false);
|
|
||||||
|
|
||||||
const handleClose = React.useCallback(() => {
|
const handleClose = React.useCallback(() => {
|
||||||
setModalIsShown(false);
|
setAppState({ openDialog: null });
|
||||||
}, []);
|
}, [setAppState]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<MenuItem
|
{appState.openDialog === "jsonExport" && (
|
||||||
icon={ExportIcon}
|
|
||||||
label={t("buttons.export")}
|
|
||||||
onClick={() => {
|
|
||||||
setModalIsShown(true);
|
|
||||||
}}
|
|
||||||
dataTestId="json-export-button"
|
|
||||||
/>
|
|
||||||
{modalIsShown && (
|
|
||||||
<Dialog onCloseRequest={handleClose} title={t("buttons.export")}>
|
<Dialog onCloseRequest={handleClose} title={t("buttons.export")}>
|
||||||
<JSONExportModal
|
<JSONExportModal
|
||||||
elements={elements}
|
elements={elements}
|
||||||
|
|||||||
@@ -80,12 +80,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.layer-ui__wrapper__footer-center {
|
|
||||||
pointer-events: none;
|
|
||||||
& > * {
|
|
||||||
pointer-events: all;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.layer-ui__wrapper__footer-left,
|
.layer-ui__wrapper__footer-left,
|
||||||
.layer-ui__wrapper__footer-right,
|
.layer-ui__wrapper__footer-right,
|
||||||
.disable-zen-mode--visible {
|
.disable-zen-mode--visible {
|
||||||
|
|||||||
+78
-144
@@ -8,10 +8,16 @@ import { NonDeletedExcalidrawElement } from "../element/types";
|
|||||||
import { Language, t } from "../i18n";
|
import { Language, t } from "../i18n";
|
||||||
import { calculateScrollCenter } from "../scene";
|
import { calculateScrollCenter } from "../scene";
|
||||||
import { ExportType } from "../scene/types";
|
import { ExportType } from "../scene/types";
|
||||||
import { AppProps, AppState, ExcalidrawProps, BinaryFiles } from "../types";
|
import {
|
||||||
import { muteFSAbortError } from "../utils";
|
AppProps,
|
||||||
|
AppState,
|
||||||
|
ExcalidrawProps,
|
||||||
|
BinaryFiles,
|
||||||
|
UIChildrenComponents,
|
||||||
|
UIWelcomeScreenComponents,
|
||||||
|
} from "../types";
|
||||||
|
import { muteFSAbortError, getReactChildren } from "../utils";
|
||||||
import { SelectedShapeActions, ShapesSwitcher } from "./Actions";
|
import { SelectedShapeActions, ShapesSwitcher } from "./Actions";
|
||||||
import CollabButton from "./CollabButton";
|
|
||||||
import { ErrorDialog } from "./ErrorDialog";
|
import { ErrorDialog } from "./ErrorDialog";
|
||||||
import { ExportCB, ImageExportDialog } from "./ImageExportDialog";
|
import { ExportCB, ImageExportDialog } from "./ImageExportDialog";
|
||||||
import { FixedSideContainer } from "./FixedSideContainer";
|
import { FixedSideContainer } from "./FixedSideContainer";
|
||||||
@@ -35,35 +41,24 @@ import "./LayerUI.scss";
|
|||||||
import "./Toolbar.scss";
|
import "./Toolbar.scss";
|
||||||
import { PenModeButton } from "./PenModeButton";
|
import { PenModeButton } from "./PenModeButton";
|
||||||
import { trackEvent } from "../analytics";
|
import { trackEvent } from "../analytics";
|
||||||
import { isMenuOpenAtom, useDevice } from "../components/App";
|
import { useDevice } from "../components/App";
|
||||||
import { Stats } from "./Stats";
|
import { Stats } from "./Stats";
|
||||||
import { actionToggleStats } from "../actions/actionToggleStats";
|
import { actionToggleStats } from "../actions/actionToggleStats";
|
||||||
import Footer from "./Footer";
|
import Footer from "./footer/Footer";
|
||||||
import {
|
import WelcomeScreen from "./welcome-screen/WelcomeScreen";
|
||||||
ExportImageIcon,
|
|
||||||
HamburgerMenuIcon,
|
|
||||||
WelcomeScreenMenuArrow,
|
|
||||||
WelcomeScreenTopToolbarArrow,
|
|
||||||
} from "./icons";
|
|
||||||
import { MenuLinks, Separator } from "./MenuUtils";
|
|
||||||
import { useOutsideClickHook } from "../hooks/useOutsideClick";
|
|
||||||
import WelcomeScreen from "./WelcomeScreen";
|
|
||||||
import { hostSidebarCountersAtom } from "./Sidebar/Sidebar";
|
import { hostSidebarCountersAtom } from "./Sidebar/Sidebar";
|
||||||
import { jotaiScope } from "../jotai";
|
import { jotaiScope } from "../jotai";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { LanguageList } from "../excalidraw-app/components/LanguageList";
|
import MainMenu from "./main-menu/MainMenu";
|
||||||
import WelcomeScreenDecor from "./WelcomeScreenDecor";
|
|
||||||
import { getShortcutFromShortcutName } from "../actions/shortcuts";
|
|
||||||
import MenuItem from "./MenuItem";
|
|
||||||
|
|
||||||
interface LayerUIProps {
|
interface LayerUIProps {
|
||||||
|
test: JSX.Element;
|
||||||
actionManager: ActionManager;
|
actionManager: ActionManager;
|
||||||
appState: AppState;
|
appState: AppState;
|
||||||
files: BinaryFiles;
|
files: BinaryFiles;
|
||||||
canvas: HTMLCanvasElement | null;
|
canvas: HTMLCanvasElement | null;
|
||||||
setAppState: React.Component<any, AppState>["setState"];
|
setAppState: React.Component<any, AppState>["setState"];
|
||||||
elements: readonly NonDeletedExcalidrawElement[];
|
elements: readonly NonDeletedExcalidrawElement[];
|
||||||
onCollabButtonClick?: () => void;
|
|
||||||
onLockToggle: () => void;
|
onLockToggle: () => void;
|
||||||
onPenModeToggle: () => void;
|
onPenModeToggle: () => void;
|
||||||
onInsertElements: (elements: readonly NonDeletedExcalidrawElement[]) => void;
|
onInsertElements: (elements: readonly NonDeletedExcalidrawElement[]) => void;
|
||||||
@@ -71,7 +66,6 @@ interface LayerUIProps {
|
|||||||
langCode: Language["code"];
|
langCode: Language["code"];
|
||||||
isCollaborating: boolean;
|
isCollaborating: boolean;
|
||||||
renderTopRightUI?: ExcalidrawProps["renderTopRightUI"];
|
renderTopRightUI?: ExcalidrawProps["renderTopRightUI"];
|
||||||
renderCustomFooter?: ExcalidrawProps["renderFooter"];
|
|
||||||
renderCustomStats?: ExcalidrawProps["renderCustomStats"];
|
renderCustomStats?: ExcalidrawProps["renderCustomStats"];
|
||||||
renderCustomSidebar?: ExcalidrawProps["renderSidebar"];
|
renderCustomSidebar?: ExcalidrawProps["renderSidebar"];
|
||||||
libraryReturnUrl: ExcalidrawProps["libraryReturnUrl"];
|
libraryReturnUrl: ExcalidrawProps["libraryReturnUrl"];
|
||||||
@@ -81,7 +75,9 @@ interface LayerUIProps {
|
|||||||
id: string;
|
id: string;
|
||||||
onImageAction: (data: { insertOnCanvasDirectly: boolean }) => void;
|
onImageAction: (data: { insertOnCanvasDirectly: boolean }) => void;
|
||||||
renderWelcomeScreen: boolean;
|
renderWelcomeScreen: boolean;
|
||||||
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LayerUI = ({
|
const LayerUI = ({
|
||||||
actionManager,
|
actionManager,
|
||||||
appState,
|
appState,
|
||||||
@@ -89,14 +85,12 @@ const LayerUI = ({
|
|||||||
setAppState,
|
setAppState,
|
||||||
elements,
|
elements,
|
||||||
canvas,
|
canvas,
|
||||||
onCollabButtonClick,
|
|
||||||
onLockToggle,
|
onLockToggle,
|
||||||
onPenModeToggle,
|
onPenModeToggle,
|
||||||
onInsertElements,
|
onInsertElements,
|
||||||
showExitZenModeBtn,
|
showExitZenModeBtn,
|
||||||
isCollaborating,
|
isCollaborating,
|
||||||
renderTopRightUI,
|
renderTopRightUI,
|
||||||
renderCustomFooter,
|
|
||||||
renderCustomStats,
|
renderCustomStats,
|
||||||
renderCustomSidebar,
|
renderCustomSidebar,
|
||||||
libraryReturnUrl,
|
libraryReturnUrl,
|
||||||
@@ -106,9 +100,32 @@ const LayerUI = ({
|
|||||||
id,
|
id,
|
||||||
onImageAction,
|
onImageAction,
|
||||||
renderWelcomeScreen,
|
renderWelcomeScreen,
|
||||||
|
children,
|
||||||
}: LayerUIProps) => {
|
}: LayerUIProps) => {
|
||||||
const device = useDevice();
|
const device = useDevice();
|
||||||
|
|
||||||
|
const [childrenComponents, restChildren] =
|
||||||
|
getReactChildren<UIChildrenComponents>(children, {
|
||||||
|
Menu: true,
|
||||||
|
FooterCenter: true,
|
||||||
|
WelcomeScreen: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [WelcomeScreenComponents] = getReactChildren<UIWelcomeScreenComponents>(
|
||||||
|
renderWelcomeScreen
|
||||||
|
? (
|
||||||
|
childrenComponents?.WelcomeScreen ?? (
|
||||||
|
<WelcomeScreen>
|
||||||
|
<WelcomeScreen.Center />
|
||||||
|
<WelcomeScreen.Hints.MenuHint />
|
||||||
|
<WelcomeScreen.Hints.ToolbarHint />
|
||||||
|
<WelcomeScreen.Hints.HelpHint />
|
||||||
|
</WelcomeScreen>
|
||||||
|
)
|
||||||
|
)?.props?.children
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
|
||||||
const renderJSONExportDialog = () => {
|
const renderJSONExportDialog = () => {
|
||||||
if (!UIOptions.canvasActions.export) {
|
if (!UIOptions.canvasActions.export) {
|
||||||
return null;
|
return null;
|
||||||
@@ -122,6 +139,7 @@ const LayerUI = ({
|
|||||||
actionManager={actionManager}
|
actionManager={actionManager}
|
||||||
exportOpts={UIOptions.canvasActions.export}
|
exportOpts={UIOptions.canvasActions.export}
|
||||||
canvas={canvas}
|
canvas={canvas}
|
||||||
|
setAppState={setAppState}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -175,97 +193,37 @@ const LayerUI = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const [isMenuOpen, setIsMenuOpen] = useAtom(isMenuOpenAtom);
|
const renderMenu = () => {
|
||||||
const menuRef = useOutsideClickHook(() => setIsMenuOpen(false));
|
return (
|
||||||
|
childrenComponents.Menu || (
|
||||||
|
<MainMenu>
|
||||||
|
<MainMenu.DefaultItems.LoadScene />
|
||||||
|
<MainMenu.DefaultItems.SaveToActiveFile />
|
||||||
|
{/* FIXME we should to test for this inside the item itself */}
|
||||||
|
{UIOptions.canvasActions.export && <MainMenu.DefaultItems.Export />}
|
||||||
|
{/* FIXME we should to test for this inside the item itself */}
|
||||||
|
{UIOptions.canvasActions.saveAsImage && (
|
||||||
|
<MainMenu.DefaultItems.SaveAsImage />
|
||||||
|
)}
|
||||||
|
<MainMenu.DefaultItems.Help />
|
||||||
|
<MainMenu.DefaultItems.ClearCanvas />
|
||||||
|
<MainMenu.Separator />
|
||||||
|
<MainMenu.Group title="Excalidraw links">
|
||||||
|
<MainMenu.DefaultItems.Socials />
|
||||||
|
</MainMenu.Group>
|
||||||
|
<MainMenu.Separator />
|
||||||
|
<MainMenu.DefaultItems.ToggleTheme />
|
||||||
|
<MainMenu.DefaultItems.ChangeCanvasBackground />
|
||||||
|
</MainMenu>
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
||||||
const renderCanvasActions = () => (
|
const renderCanvasActions = () => (
|
||||||
<div style={{ position: "relative" }}>
|
<div style={{ position: "relative" }}>
|
||||||
<WelcomeScreenDecor
|
{WelcomeScreenComponents.MenuHint}
|
||||||
shouldRender={renderWelcomeScreen && !appState.isLoading}
|
{/* wrapping to Fragment stops React from occasionally complaining
|
||||||
>
|
about identical Keys */}
|
||||||
<div className="virgil WelcomeScreen-decor WelcomeScreen-decor--menu-pointer">
|
<>{renderMenu()}</>
|
||||||
{WelcomeScreenMenuArrow}
|
|
||||||
<div>{t("welcomeScreen.menuHints")}</div>
|
|
||||||
</div>
|
|
||||||
</WelcomeScreenDecor>
|
|
||||||
|
|
||||||
<button
|
|
||||||
data-prevent-outside-click
|
|
||||||
className={clsx("menu-button", "zen-mode-transition", {
|
|
||||||
"transition-left": appState.zenModeEnabled,
|
|
||||||
})}
|
|
||||||
onClick={() => setIsMenuOpen(!isMenuOpen)}
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
{HamburgerMenuIcon}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{isMenuOpen && (
|
|
||||||
<div
|
|
||||||
ref={menuRef}
|
|
||||||
style={{ position: "absolute", top: "100%", marginTop: ".25rem" }}
|
|
||||||
>
|
|
||||||
<Section heading="canvasActions">
|
|
||||||
{/* the zIndex ensures this menu has higher stacking order,
|
|
||||||
see https://github.com/excalidraw/excalidraw/pull/1445 */}
|
|
||||||
<Island
|
|
||||||
className="menu-container"
|
|
||||||
padding={2}
|
|
||||||
style={{ zIndex: 1 }}
|
|
||||||
>
|
|
||||||
{!appState.viewModeEnabled &&
|
|
||||||
actionManager.renderAction("loadScene")}
|
|
||||||
{/* // TODO barnabasmolnar/editor-redesign */}
|
|
||||||
{/* is this fine here? */}
|
|
||||||
{appState.fileHandle &&
|
|
||||||
actionManager.renderAction("saveToActiveFile")}
|
|
||||||
{renderJSONExportDialog()}
|
|
||||||
<MenuItem
|
|
||||||
label={t("buttons.exportImage")}
|
|
||||||
icon={ExportImageIcon}
|
|
||||||
dataTestId="image-export-button"
|
|
||||||
onClick={() => setAppState({ openDialog: "imageExport" })}
|
|
||||||
shortcut={getShortcutFromShortcutName("imageExport")}
|
|
||||||
/>
|
|
||||||
{onCollabButtonClick && (
|
|
||||||
<CollabButton
|
|
||||||
isCollaborating={isCollaborating}
|
|
||||||
collaboratorCount={appState.collaborators.size}
|
|
||||||
onClick={onCollabButtonClick}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{actionManager.renderAction("toggleShortcuts", undefined, true)}
|
|
||||||
{!appState.viewModeEnabled &&
|
|
||||||
actionManager.renderAction("clearCanvas")}
|
|
||||||
<Separator />
|
|
||||||
<MenuLinks />
|
|
||||||
<Separator />
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
|
||||||
rowGap: ".5rem",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div>{actionManager.renderAction("toggleTheme")}</div>
|
|
||||||
<div style={{ padding: "0 0.625rem" }}>
|
|
||||||
<LanguageList style={{ width: "100%" }} />
|
|
||||||
</div>
|
|
||||||
{!appState.viewModeEnabled && (
|
|
||||||
<div>
|
|
||||||
<div style={{ fontSize: ".75rem", marginBottom: ".5rem" }}>
|
|
||||||
{t("labels.canvasBackground")}
|
|
||||||
</div>
|
|
||||||
<div style={{ padding: "0 0.625rem" }}>
|
|
||||||
{actionManager.renderAction("changeViewBackgroundColor")}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</Island>
|
|
||||||
</Section>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -302,9 +260,7 @@ const LayerUI = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<FixedSideContainer side="top">
|
<FixedSideContainer side="top">
|
||||||
{renderWelcomeScreen && !appState.isLoading && (
|
{WelcomeScreenComponents.Center}
|
||||||
<WelcomeScreen appState={appState} actionManager={actionManager} />
|
|
||||||
)}
|
|
||||||
<div className="App-menu App-menu_top">
|
<div className="App-menu App-menu_top">
|
||||||
<Stack.Col
|
<Stack.Col
|
||||||
gap={6}
|
gap={6}
|
||||||
@@ -319,17 +275,7 @@ const LayerUI = ({
|
|||||||
<Section heading="shapes" className="shapes-section">
|
<Section heading="shapes" className="shapes-section">
|
||||||
{(heading: React.ReactNode) => (
|
{(heading: React.ReactNode) => (
|
||||||
<div style={{ position: "relative" }}>
|
<div style={{ position: "relative" }}>
|
||||||
<WelcomeScreenDecor
|
{WelcomeScreenComponents.ToolbarHint}
|
||||||
shouldRender={renderWelcomeScreen && !appState.isLoading}
|
|
||||||
>
|
|
||||||
<div className="virgil WelcomeScreen-decor WelcomeScreen-decor--top-toolbar-pointer">
|
|
||||||
<div className="WelcomeScreen-decor--top-toolbar-pointer__label">
|
|
||||||
{t("welcomeScreen.toolbarHints")}
|
|
||||||
</div>
|
|
||||||
{WelcomeScreenTopToolbarArrow}
|
|
||||||
</div>
|
|
||||||
</WelcomeScreenDecor>
|
|
||||||
|
|
||||||
<Stack.Col gap={4} align="start">
|
<Stack.Col gap={4} align="start">
|
||||||
<Stack.Row
|
<Stack.Row
|
||||||
gap={1}
|
gap={1}
|
||||||
@@ -396,18 +342,7 @@ const LayerUI = ({
|
|||||||
},
|
},
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<UserList
|
<UserList collaborators={appState.collaborators} />
|
||||||
collaborators={appState.collaborators}
|
|
||||||
actionManager={actionManager}
|
|
||||||
/>
|
|
||||||
{onCollabButtonClick && (
|
|
||||||
<CollabButton
|
|
||||||
isInHamburgerMenu={false}
|
|
||||||
isCollaborating={isCollaborating}
|
|
||||||
collaboratorCount={appState.collaborators.size}
|
|
||||||
onClick={onCollabButtonClick}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{renderTopRightUI?.(device.isMobile, appState)}
|
{renderTopRightUI?.(device.isMobile, appState)}
|
||||||
{!appState.viewModeEnabled && (
|
{!appState.viewModeEnabled && (
|
||||||
<LibraryButton appState={appState} setAppState={setAppState} />
|
<LibraryButton appState={appState} setAppState={setAppState} />
|
||||||
@@ -437,6 +372,7 @@ const LayerUI = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{restChildren}
|
||||||
{appState.isLoading && <LoadingMessage delay={250} />}
|
{appState.isLoading && <LoadingMessage delay={250} />}
|
||||||
{appState.errorMessage && (
|
{appState.errorMessage && (
|
||||||
<ErrorDialog
|
<ErrorDialog
|
||||||
@@ -452,6 +388,7 @@ const LayerUI = ({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{renderImageExportDialog()}
|
{renderImageExportDialog()}
|
||||||
|
{renderJSONExportDialog()}
|
||||||
{appState.pasteDialog.shown && (
|
{appState.pasteDialog.shown && (
|
||||||
<PasteChartDialog
|
<PasteChartDialog
|
||||||
setAppState={setAppState}
|
setAppState={setAppState}
|
||||||
@@ -466,24 +403,22 @@ const LayerUI = ({
|
|||||||
)}
|
)}
|
||||||
{device.isMobile && (
|
{device.isMobile && (
|
||||||
<MobileMenu
|
<MobileMenu
|
||||||
renderWelcomeScreen={renderWelcomeScreen}
|
|
||||||
appState={appState}
|
appState={appState}
|
||||||
elements={elements}
|
elements={elements}
|
||||||
actionManager={actionManager}
|
actionManager={actionManager}
|
||||||
renderJSONExportDialog={renderJSONExportDialog}
|
renderJSONExportDialog={renderJSONExportDialog}
|
||||||
renderImageExportDialog={renderImageExportDialog}
|
renderImageExportDialog={renderImageExportDialog}
|
||||||
setAppState={setAppState}
|
setAppState={setAppState}
|
||||||
onCollabButtonClick={onCollabButtonClick}
|
|
||||||
onLockToggle={() => onLockToggle()}
|
onLockToggle={() => onLockToggle()}
|
||||||
onPenModeToggle={onPenModeToggle}
|
onPenModeToggle={onPenModeToggle}
|
||||||
canvas={canvas}
|
canvas={canvas}
|
||||||
isCollaborating={isCollaborating}
|
|
||||||
renderCustomFooter={renderCustomFooter}
|
|
||||||
onImageAction={onImageAction}
|
onImageAction={onImageAction}
|
||||||
renderTopRightUI={renderTopRightUI}
|
renderTopRightUI={renderTopRightUI}
|
||||||
renderCustomStats={renderCustomStats}
|
renderCustomStats={renderCustomStats}
|
||||||
renderSidebars={renderSidebars}
|
renderSidebars={renderSidebars}
|
||||||
device={device}
|
device={device}
|
||||||
|
renderMenu={renderMenu}
|
||||||
|
welcomeScreenCenter={WelcomeScreenComponents.Center}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -508,11 +443,11 @@ const LayerUI = ({
|
|||||||
>
|
>
|
||||||
{renderFixedSideContainer()}
|
{renderFixedSideContainer()}
|
||||||
<Footer
|
<Footer
|
||||||
renderWelcomeScreen={renderWelcomeScreen}
|
|
||||||
appState={appState}
|
appState={appState}
|
||||||
actionManager={actionManager}
|
actionManager={actionManager}
|
||||||
renderCustomFooter={renderCustomFooter}
|
|
||||||
showExitZenModeBtn={showExitZenModeBtn}
|
showExitZenModeBtn={showExitZenModeBtn}
|
||||||
|
footerCenter={childrenComponents.FooterCenter}
|
||||||
|
welcomeScreenHelp={WelcomeScreenComponents.HelpHint}
|
||||||
/>
|
/>
|
||||||
{appState.showStats && (
|
{appState.showStats && (
|
||||||
<Stats
|
<Stats
|
||||||
@@ -560,7 +495,6 @@ const areEqual = (prev: LayerUIProps, next: LayerUIProps) => {
|
|||||||
const keys = Object.keys(prevAppState) as (keyof Partial<AppState>)[];
|
const keys = Object.keys(prevAppState) as (keyof Partial<AppState>)[];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
prev.renderCustomFooter === next.renderCustomFooter &&
|
|
||||||
prev.renderTopRightUI === next.renderTopRightUI &&
|
prev.renderTopRightUI === next.renderTopRightUI &&
|
||||||
prev.renderCustomStats === next.renderCustomStats &&
|
prev.renderCustomStats === next.renderCustomStats &&
|
||||||
prev.renderCustomSidebar === next.renderCustomSidebar &&
|
prev.renderCustomSidebar === next.renderCustomSidebar &&
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const LibraryButton: React.FC<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<label title={`${capitalizeString(t("toolBar.library"))} — 0`}>
|
<label title={`${capitalizeString(t("toolBar.library"))}`}>
|
||||||
<input
|
<input
|
||||||
className="ToolIcon_type_checkbox"
|
className="ToolIcon_type_checkbox"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
|
|||||||
@@ -129,4 +129,27 @@
|
|||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.layer-ui__sidebar__header .dropdown-menu {
|
||||||
|
&.dropdown-menu--mobile {
|
||||||
|
top: 100%;
|
||||||
|
}
|
||||||
|
.dropdown-menu-container {
|
||||||
|
--gap: 0;
|
||||||
|
z-index: 1;
|
||||||
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
left: 0;
|
||||||
|
|
||||||
|
:root[dir="rtl"] & {
|
||||||
|
right: 0;
|
||||||
|
left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
width: 196px;
|
||||||
|
box-shadow: var(--library-dropdown-shadow);
|
||||||
|
border-radius: var(--border-radius-lg);
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,14 +13,15 @@ import {
|
|||||||
import { ToolButton } from "./ToolButton";
|
import { ToolButton } from "./ToolButton";
|
||||||
import { fileOpen } from "../data/filesystem";
|
import { fileOpen } from "../data/filesystem";
|
||||||
import { muteFSAbortError } from "../utils";
|
import { muteFSAbortError } from "../utils";
|
||||||
import { useAtom } from "jotai";
|
import { atom, useAtom } from "jotai";
|
||||||
import { jotaiScope } from "../jotai";
|
import { jotaiScope } from "../jotai";
|
||||||
import ConfirmDialog from "./ConfirmDialog";
|
import ConfirmDialog from "./ConfirmDialog";
|
||||||
import PublishLibrary from "./PublishLibrary";
|
import PublishLibrary from "./PublishLibrary";
|
||||||
import { Dialog } from "./Dialog";
|
import { Dialog } from "./Dialog";
|
||||||
import { useOutsideClickHook } from "../hooks/useOutsideClick";
|
|
||||||
import MenuItem from "./MenuItem";
|
import DropdownMenu from "./dropdownMenu/DropdownMenu";
|
||||||
import { isDropdownOpenAtom } from "./App";
|
|
||||||
|
export const isLibraryMenuOpenAtom = atom(false);
|
||||||
|
|
||||||
const getSelectedItems = (
|
const getSelectedItems = (
|
||||||
libraryItems: LibraryItems,
|
libraryItems: LibraryItems,
|
||||||
@@ -45,7 +46,9 @@ export const LibraryMenuHeader: React.FC<{
|
|||||||
appState,
|
appState,
|
||||||
}) => {
|
}) => {
|
||||||
const [libraryItemsData] = useAtom(libraryItemsAtom, jotaiScope);
|
const [libraryItemsData] = useAtom(libraryItemsAtom, jotaiScope);
|
||||||
|
const [isLibraryMenuOpen, setIsLibraryMenuOpen] = useAtom(
|
||||||
|
isLibraryMenuOpenAtom,
|
||||||
|
);
|
||||||
const renderRemoveLibAlert = useCallback(() => {
|
const renderRemoveLibAlert = useCallback(() => {
|
||||||
const content = selectedItems.length
|
const content = selectedItems.length
|
||||||
? t("alerts.removeItemsFromsLibrary", { count: selectedItems.length })
|
? t("alerts.removeItemsFromsLibrary", { count: selectedItems.length })
|
||||||
@@ -173,85 +176,86 @@ export const LibraryMenuHeader: React.FC<{
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const [isDropdownOpen, setIsDropdownOpen] = useAtom(isDropdownOpenAtom);
|
const renderLibraryMenu = () => {
|
||||||
const dropdownRef = useOutsideClickHook(() => setIsDropdownOpen(false));
|
return (
|
||||||
|
<DropdownMenu open={isLibraryMenuOpen}>
|
||||||
|
<DropdownMenu.Trigger
|
||||||
|
className="Sidebar__dropdown-btn"
|
||||||
|
onToggle={() => setIsLibraryMenuOpen(!isLibraryMenuOpen)}
|
||||||
|
>
|
||||||
|
{DotsIcon}
|
||||||
|
</DropdownMenu.Trigger>
|
||||||
|
<DropdownMenu.Content
|
||||||
|
onClickOutside={() => setIsLibraryMenuOpen(false)}
|
||||||
|
className="library-menu"
|
||||||
|
>
|
||||||
|
{!itemsSelected && (
|
||||||
|
<DropdownMenu.Item
|
||||||
|
onSelect={onLibraryImport}
|
||||||
|
icon={LoadIcon}
|
||||||
|
data-testid="lib-dropdown--load"
|
||||||
|
>
|
||||||
|
{t("buttons.load")}
|
||||||
|
</DropdownMenu.Item>
|
||||||
|
)}
|
||||||
|
{!!items.length && (
|
||||||
|
<DropdownMenu.Item
|
||||||
|
onSelect={onLibraryExport}
|
||||||
|
icon={ExportIcon}
|
||||||
|
data-testid="lib-dropdown--export"
|
||||||
|
>
|
||||||
|
{t("buttons.export")}
|
||||||
|
</DropdownMenu.Item>
|
||||||
|
)}
|
||||||
|
{!!items.length && (
|
||||||
|
<DropdownMenu.Item
|
||||||
|
onSelect={() => setShowRemoveLibAlert(true)}
|
||||||
|
icon={TrashIcon}
|
||||||
|
>
|
||||||
|
{resetLabel}
|
||||||
|
</DropdownMenu.Item>
|
||||||
|
)}
|
||||||
|
{itemsSelected && (
|
||||||
|
<DropdownMenu.Item
|
||||||
|
icon={publishIcon}
|
||||||
|
onSelect={() => setShowPublishLibraryDialog(true)}
|
||||||
|
data-testid="lib-dropdown--remove"
|
||||||
|
>
|
||||||
|
{t("buttons.publishLibrary")}
|
||||||
|
</DropdownMenu.Item>
|
||||||
|
)}
|
||||||
|
</DropdownMenu.Content>
|
||||||
|
</DropdownMenu>
|
||||||
|
);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div style={{ position: "relative" }}>
|
<div style={{ position: "relative" }}>
|
||||||
<button
|
{renderLibraryMenu()}
|
||||||
type="button"
|
|
||||||
className="Sidebar__dropdown-btn"
|
|
||||||
data-prevent-outside-click
|
|
||||||
onClick={() => setIsDropdownOpen(!isDropdownOpen)}
|
|
||||||
>
|
|
||||||
{DotsIcon}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{selectedItems.length > 0 && (
|
{selectedItems.length > 0 && (
|
||||||
<div className="library-actions-counter">{selectedItems.length}</div>
|
<div className="library-actions-counter">{selectedItems.length}</div>
|
||||||
)}
|
)}
|
||||||
|
{showRemoveLibAlert && renderRemoveLibAlert()}
|
||||||
{isDropdownOpen && (
|
{showPublishLibraryDialog && (
|
||||||
<div
|
<PublishLibrary
|
||||||
className="Sidebar__dropdown-content menu-container"
|
onClose={() => setShowPublishLibraryDialog(false)}
|
||||||
ref={dropdownRef}
|
libraryItems={getSelectedItems(
|
||||||
>
|
libraryItemsData.libraryItems,
|
||||||
{!itemsSelected && (
|
selectedItems,
|
||||||
<MenuItem
|
|
||||||
label={t("buttons.load")}
|
|
||||||
icon={LoadIcon}
|
|
||||||
dataTestId="lib-dropdown--load"
|
|
||||||
onClick={onLibraryImport}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
{showRemoveLibAlert && renderRemoveLibAlert()}
|
appState={appState}
|
||||||
{showPublishLibraryDialog && (
|
onSuccess={(data) =>
|
||||||
<PublishLibrary
|
onPublishLibSuccess(data, libraryItemsData.libraryItems)
|
||||||
onClose={() => setShowPublishLibraryDialog(false)}
|
}
|
||||||
libraryItems={getSelectedItems(
|
onError={(error) => window.alert(error)}
|
||||||
libraryItemsData.libraryItems,
|
updateItemsInStorage={() =>
|
||||||
selectedItems,
|
library.setLibrary(libraryItemsData.libraryItems)
|
||||||
)}
|
}
|
||||||
appState={appState}
|
onRemove={(id: string) =>
|
||||||
onSuccess={(data) =>
|
onSelectItems(selectedItems.filter((_id) => _id !== id))
|
||||||
onPublishLibSuccess(data, libraryItemsData.libraryItems)
|
}
|
||||||
}
|
/>
|
||||||
onError={(error) => window.alert(error)}
|
|
||||||
updateItemsInStorage={() =>
|
|
||||||
library.setLibrary(libraryItemsData.libraryItems)
|
|
||||||
}
|
|
||||||
onRemove={(id: string) =>
|
|
||||||
onSelectItems(selectedItems.filter((_id) => _id !== id))
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{publishLibSuccess && renderPublishSuccess()}
|
|
||||||
{!!items.length && (
|
|
||||||
<>
|
|
||||||
<MenuItem
|
|
||||||
label={t("buttons.export")}
|
|
||||||
icon={ExportIcon}
|
|
||||||
onClick={onLibraryExport}
|
|
||||||
dataTestId="lib-dropdown--export"
|
|
||||||
/>
|
|
||||||
<MenuItem
|
|
||||||
label={resetLabel}
|
|
||||||
icon={TrashIcon}
|
|
||||||
onClick={() => setShowRemoveLibAlert(true)}
|
|
||||||
dataTestId="lib-dropdown--remove"
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{itemsSelected && (
|
|
||||||
<MenuItem
|
|
||||||
label={t("buttons.publishLibrary")}
|
|
||||||
icon={publishIcon}
|
|
||||||
dataTestId="lib-dropdown--publish"
|
|
||||||
onClick={() => setShowPublishLibraryDialog(true)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
|
{publishLibSuccess && renderPublishSuccess()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ export const LibraryUnit = ({
|
|||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
|
svg.querySelector(".style-fonts")?.remove();
|
||||||
node.innerHTML = svg.outerHTML;
|
node.innerHTML = svg.outerHTML;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
@import "../css/variables.module";
|
|
||||||
|
|
||||||
.excalidraw {
|
|
||||||
.menu-container {
|
|
||||||
background-color: #fff !important;
|
|
||||||
max-height: calc(100vh - 150px);
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-button {
|
|
||||||
@include outlineButtonStyles;
|
|
||||||
background-color: var(--island-bg-color);
|
|
||||||
width: var(--lg-button-size);
|
|
||||||
height: var(--lg-button-size);
|
|
||||||
|
|
||||||
svg {
|
|
||||||
width: var(--lg-icon-size);
|
|
||||||
height: var(--lg-icon-size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-item {
|
|
||||||
display: flex;
|
|
||||||
background-color: transparent;
|
|
||||||
border: 0;
|
|
||||||
align-items: center;
|
|
||||||
padding: 0 0.625rem;
|
|
||||||
height: 2rem;
|
|
||||||
column-gap: 0.625rem;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
color: var(--color-gray-100);
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: var(--border-radius-md);
|
|
||||||
width: 100%;
|
|
||||||
box-sizing: border-box;
|
|
||||||
font-weight: normal;
|
|
||||||
font-family: inherit;
|
|
||||||
|
|
||||||
@media screen and (min-width: 1921px) {
|
|
||||||
height: 2.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__text {
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
overflow: hidden;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__shortcut {
|
|
||||||
margin-inline-start: auto;
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background-color: var(--button-hover);
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
svg {
|
|
||||||
width: 1rem;
|
|
||||||
height: 1rem;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.active-collab {
|
|
||||||
background-color: #ecfdf5;
|
|
||||||
color: #064e3c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.theme--dark {
|
|
||||||
.menu-item {
|
|
||||||
color: var(--color-gray-40);
|
|
||||||
|
|
||||||
&.active-collab {
|
|
||||||
background-color: #064e3c;
|
|
||||||
color: #ecfdf5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-container {
|
|
||||||
background-color: var(--color-gray-90) !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import clsx from "clsx";
|
|
||||||
import "./Menu.scss";
|
|
||||||
|
|
||||||
interface MenuProps {
|
|
||||||
icon: JSX.Element;
|
|
||||||
onClick: () => void;
|
|
||||||
label: string;
|
|
||||||
dataTestId: string;
|
|
||||||
shortcut?: string;
|
|
||||||
isCollaborating?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const MenuItem = ({
|
|
||||||
icon,
|
|
||||||
onClick,
|
|
||||||
label,
|
|
||||||
dataTestId,
|
|
||||||
shortcut,
|
|
||||||
isCollaborating,
|
|
||||||
}: MenuProps) => {
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
className={clsx("menu-item", { "active-collab": isCollaborating })}
|
|
||||||
aria-label={label}
|
|
||||||
onClick={onClick}
|
|
||||||
data-testid={dataTestId}
|
|
||||||
title={label}
|
|
||||||
type="button"
|
|
||||||
>
|
|
||||||
<div className="menu-item__icon">{icon}</div>
|
|
||||||
<div className="menu-item__text">{label}</div>
|
|
||||||
{shortcut && <div className="menu-item__shortcut">{shortcut}</div>}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default MenuItem;
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
import { GithubIcon, DiscordIcon, PlusPromoIcon, TwitterIcon } from "./icons";
|
|
||||||
|
|
||||||
export const MenuLinks = () => (
|
|
||||||
<>
|
|
||||||
<a
|
|
||||||
href="https://plus.excalidraw.com/plus?utm_source=excalidraw&utm_medium=app&utm_content=hamburger"
|
|
||||||
target="_blank"
|
|
||||||
rel="noreferrer"
|
|
||||||
className="menu-item"
|
|
||||||
style={{ color: "var(--color-promo)" }}
|
|
||||||
>
|
|
||||||
<div className="menu-item__icon">{PlusPromoIcon}</div>
|
|
||||||
<div className="menu-item__text">Excalidraw+</div>
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
className="menu-item"
|
|
||||||
href="https://github.com/excalidraw/excalidraw"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
<div className="menu-item__icon">{GithubIcon}</div>
|
|
||||||
<div className="menu-item__text">GitHub</div>
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
className="menu-item"
|
|
||||||
target="_blank"
|
|
||||||
href="https://discord.gg/UexuTaE"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
<div className="menu-item__icon">{DiscordIcon}</div>
|
|
||||||
<div className="menu-item__text">Discord</div>
|
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
className="menu-item"
|
|
||||||
target="_blank"
|
|
||||||
href="https://twitter.com/excalidraw"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
<div className="menu-item__icon">{TwitterIcon}</div>
|
|
||||||
<div className="menu-item__text">Twitter</div>
|
|
||||||
</a>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
export const Separator = () => (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
height: "1px",
|
|
||||||
backgroundColor: "var(--default-border-color)",
|
|
||||||
margin: ".5rem 0",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
+17
-118
@@ -1,5 +1,10 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { AppState, Device, ExcalidrawProps } from "../types";
|
import {
|
||||||
|
AppState,
|
||||||
|
Device,
|
||||||
|
ExcalidrawProps,
|
||||||
|
UIWelcomeScreenComponents,
|
||||||
|
} from "../types";
|
||||||
import { ActionManager } from "../actions/manager";
|
import { ActionManager } from "../actions/manager";
|
||||||
import { t } from "../i18n";
|
import { t } from "../i18n";
|
||||||
import Stack from "./Stack";
|
import Stack from "./Stack";
|
||||||
@@ -11,18 +16,12 @@ import { HintViewer } from "./HintViewer";
|
|||||||
import { calculateScrollCenter } from "../scene";
|
import { calculateScrollCenter } from "../scene";
|
||||||
import { SelectedShapeActions, ShapesSwitcher } from "./Actions";
|
import { SelectedShapeActions, ShapesSwitcher } from "./Actions";
|
||||||
import { Section } from "./Section";
|
import { Section } from "./Section";
|
||||||
import CollabButton from "./CollabButton";
|
|
||||||
import { SCROLLBAR_WIDTH, SCROLLBAR_MARGIN } from "../scene/scrollbars";
|
import { SCROLLBAR_WIDTH, SCROLLBAR_MARGIN } from "../scene/scrollbars";
|
||||||
import { LockButton } from "./LockButton";
|
import { LockButton } from "./LockButton";
|
||||||
import { UserList } from "./UserList";
|
|
||||||
import { LibraryButton } from "./LibraryButton";
|
import { LibraryButton } from "./LibraryButton";
|
||||||
import { PenModeButton } from "./PenModeButton";
|
import { PenModeButton } from "./PenModeButton";
|
||||||
import { Stats } from "./Stats";
|
import { Stats } from "./Stats";
|
||||||
import { actionToggleStats } from "../actions";
|
import { actionToggleStats } from "../actions";
|
||||||
import { MenuLinks, Separator } from "./MenuUtils";
|
|
||||||
import WelcomeScreen from "./WelcomeScreen";
|
|
||||||
import MenuItem from "./MenuItem";
|
|
||||||
import { ExportImageIcon } from "./icons";
|
|
||||||
|
|
||||||
type MobileMenuProps = {
|
type MobileMenuProps = {
|
||||||
appState: AppState;
|
appState: AppState;
|
||||||
@@ -31,15 +30,10 @@ type MobileMenuProps = {
|
|||||||
renderImageExportDialog: () => React.ReactNode;
|
renderImageExportDialog: () => React.ReactNode;
|
||||||
setAppState: React.Component<any, AppState>["setState"];
|
setAppState: React.Component<any, AppState>["setState"];
|
||||||
elements: readonly NonDeletedExcalidrawElement[];
|
elements: readonly NonDeletedExcalidrawElement[];
|
||||||
onCollabButtonClick?: () => void;
|
|
||||||
onLockToggle: () => void;
|
onLockToggle: () => void;
|
||||||
onPenModeToggle: () => void;
|
onPenModeToggle: () => void;
|
||||||
canvas: HTMLCanvasElement | null;
|
canvas: HTMLCanvasElement | null;
|
||||||
isCollaborating: boolean;
|
|
||||||
renderCustomFooter?: (
|
|
||||||
isMobile: boolean,
|
|
||||||
appState: AppState,
|
|
||||||
) => JSX.Element | null;
|
|
||||||
onImageAction: (data: { insertOnCanvasDirectly: boolean }) => void;
|
onImageAction: (data: { insertOnCanvasDirectly: boolean }) => void;
|
||||||
renderTopRightUI?: (
|
renderTopRightUI?: (
|
||||||
isMobile: boolean,
|
isMobile: boolean,
|
||||||
@@ -48,35 +42,30 @@ type MobileMenuProps = {
|
|||||||
renderCustomStats?: ExcalidrawProps["renderCustomStats"];
|
renderCustomStats?: ExcalidrawProps["renderCustomStats"];
|
||||||
renderSidebars: () => JSX.Element | null;
|
renderSidebars: () => JSX.Element | null;
|
||||||
device: Device;
|
device: Device;
|
||||||
renderWelcomeScreen?: boolean;
|
renderMenu: () => React.ReactNode;
|
||||||
|
welcomeScreenCenter: UIWelcomeScreenComponents["Center"];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MobileMenu = ({
|
export const MobileMenu = ({
|
||||||
appState,
|
appState,
|
||||||
elements,
|
elements,
|
||||||
actionManager,
|
actionManager,
|
||||||
renderJSONExportDialog,
|
|
||||||
renderImageExportDialog,
|
|
||||||
setAppState,
|
setAppState,
|
||||||
onCollabButtonClick,
|
|
||||||
onLockToggle,
|
onLockToggle,
|
||||||
onPenModeToggle,
|
onPenModeToggle,
|
||||||
canvas,
|
canvas,
|
||||||
isCollaborating,
|
|
||||||
renderCustomFooter,
|
|
||||||
onImageAction,
|
onImageAction,
|
||||||
renderTopRightUI,
|
renderTopRightUI,
|
||||||
renderCustomStats,
|
renderCustomStats,
|
||||||
renderSidebars,
|
renderSidebars,
|
||||||
device,
|
device,
|
||||||
renderWelcomeScreen,
|
renderMenu,
|
||||||
|
welcomeScreenCenter,
|
||||||
}: MobileMenuProps) => {
|
}: MobileMenuProps) => {
|
||||||
const renderToolbar = () => {
|
const renderToolbar = () => {
|
||||||
return (
|
return (
|
||||||
<FixedSideContainer side="top" className="App-top-bar">
|
<FixedSideContainer side="top" className="App-top-bar">
|
||||||
{renderWelcomeScreen && !appState.isLoading && (
|
{welcomeScreenCenter}
|
||||||
<WelcomeScreen appState={appState} actionManager={actionManager} />
|
|
||||||
)}
|
|
||||||
<Section heading="shapes">
|
<Section heading="shapes">
|
||||||
{(heading: React.ReactNode) => (
|
{(heading: React.ReactNode) => (
|
||||||
<Stack.Col gap={4} align="center">
|
<Stack.Col gap={4} align="center">
|
||||||
@@ -84,20 +73,6 @@ export const MobileMenu = ({
|
|||||||
<Island padding={1} className="App-toolbar App-toolbar--mobile">
|
<Island padding={1} className="App-toolbar App-toolbar--mobile">
|
||||||
{heading}
|
{heading}
|
||||||
<Stack.Row gap={1}>
|
<Stack.Row gap={1}>
|
||||||
{/* <PenModeButton
|
|
||||||
checked={appState.penMode}
|
|
||||||
onChange={onPenModeToggle}
|
|
||||||
title={t("toolBar.penMode")}
|
|
||||||
isMobile
|
|
||||||
penDetected={appState.penDetected}
|
|
||||||
/>
|
|
||||||
<LockButton
|
|
||||||
checked={appState.activeTool.locked}
|
|
||||||
onChange={onLockToggle}
|
|
||||||
title={t("toolBar.lock")}
|
|
||||||
isMobile
|
|
||||||
/>
|
|
||||||
<div className="App-toolbar__divider"></div> */}
|
|
||||||
<ShapesSwitcher
|
<ShapesSwitcher
|
||||||
appState={appState}
|
appState={appState}
|
||||||
canvas={canvas}
|
canvas={canvas}
|
||||||
@@ -119,7 +94,6 @@ export const MobileMenu = ({
|
|||||||
title={t("toolBar.penMode")}
|
title={t("toolBar.penMode")}
|
||||||
isMobile
|
isMobile
|
||||||
penDetected={appState.penDetected}
|
penDetected={appState.penDetected}
|
||||||
// penDetected={true}
|
|
||||||
/>
|
/>
|
||||||
<LockButton
|
<LockButton
|
||||||
checked={appState.activeTool.locked}
|
checked={appState.activeTool.locked}
|
||||||
@@ -151,16 +125,12 @@ export const MobileMenu = ({
|
|||||||
|
|
||||||
const renderAppToolbar = () => {
|
const renderAppToolbar = () => {
|
||||||
if (appState.viewModeEnabled) {
|
if (appState.viewModeEnabled) {
|
||||||
return (
|
return <div className="App-toolbar-content">{renderMenu()}</div>;
|
||||||
<div className="App-toolbar-content">
|
|
||||||
{actionManager.renderAction("toggleCanvasMenu")}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="App-toolbar-content">
|
<div className="App-toolbar-content">
|
||||||
{actionManager.renderAction("toggleCanvasMenu")}
|
{renderMenu()}
|
||||||
{actionManager.renderAction("toggleEditMenu")}
|
{actionManager.renderAction("toggleEditMenu")}
|
||||||
{actionManager.renderAction("undo")}
|
{actionManager.renderAction("undo")}
|
||||||
{actionManager.renderAction("redo")}
|
{actionManager.renderAction("redo")}
|
||||||
@@ -172,58 +142,6 @@ export const MobileMenu = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderCanvasActions = () => {
|
|
||||||
if (appState.viewModeEnabled) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{renderJSONExportDialog()}
|
|
||||||
<MenuItem
|
|
||||||
label={t("buttons.exportImage")}
|
|
||||||
icon={ExportImageIcon}
|
|
||||||
dataTestId="image-export-button"
|
|
||||||
onClick={() => setAppState({ openDialog: "imageExport" })}
|
|
||||||
/>
|
|
||||||
{renderImageExportDialog()}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{!appState.viewModeEnabled && actionManager.renderAction("loadScene")}
|
|
||||||
{renderJSONExportDialog()}
|
|
||||||
{renderImageExportDialog()}
|
|
||||||
<MenuItem
|
|
||||||
label={t("buttons.exportImage")}
|
|
||||||
icon={ExportImageIcon}
|
|
||||||
dataTestId="image-export-button"
|
|
||||||
onClick={() => setAppState({ openDialog: "imageExport" })}
|
|
||||||
/>
|
|
||||||
{onCollabButtonClick && (
|
|
||||||
<CollabButton
|
|
||||||
isCollaborating={isCollaborating}
|
|
||||||
collaboratorCount={appState.collaborators.size}
|
|
||||||
onClick={onCollabButtonClick}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{actionManager.renderAction("toggleShortcuts", undefined, true)}
|
|
||||||
{!appState.viewModeEnabled && actionManager.renderAction("clearCanvas")}
|
|
||||||
<Separator />
|
|
||||||
<MenuLinks />
|
|
||||||
<Separator />
|
|
||||||
{!appState.viewModeEnabled && (
|
|
||||||
<div style={{ marginBottom: ".5rem" }}>
|
|
||||||
<div style={{ fontSize: ".75rem", marginBottom: ".5rem" }}>
|
|
||||||
{t("labels.canvasBackground")}
|
|
||||||
</div>
|
|
||||||
<div style={{ padding: "0 0.625rem" }}>
|
|
||||||
{actionManager.renderAction("changeViewBackgroundColor")}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{actionManager.renderAction("toggleTheme")}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{renderSidebars()}
|
{renderSidebars()}
|
||||||
@@ -248,28 +166,9 @@ export const MobileMenu = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Island padding={0}>
|
<Island padding={0}>
|
||||||
{appState.openMenu === "canvas" ? (
|
{appState.openMenu === "shape" &&
|
||||||
<Section className="App-mobile-menu" heading="canvasActions">
|
!appState.viewModeEnabled &&
|
||||||
<div className="panelColumn">
|
showSelectedShapeActions(appState, elements) ? (
|
||||||
<Stack.Col gap={2}>
|
|
||||||
{renderCanvasActions()}
|
|
||||||
{renderCustomFooter?.(true, appState)}
|
|
||||||
{appState.collaborators.size > 0 && (
|
|
||||||
<fieldset>
|
|
||||||
<legend>{t("labels.collaborators")}</legend>
|
|
||||||
<UserList
|
|
||||||
mobile
|
|
||||||
collaborators={appState.collaborators}
|
|
||||||
actionManager={actionManager}
|
|
||||||
/>
|
|
||||||
</fieldset>
|
|
||||||
)}
|
|
||||||
</Stack.Col>
|
|
||||||
</div>
|
|
||||||
</Section>
|
|
||||||
) : appState.openMenu === "shape" &&
|
|
||||||
!appState.viewModeEnabled &&
|
|
||||||
showSelectedShapeActions(appState, elements) ? (
|
|
||||||
<Section className="App-mobile-menu" heading="selectedShapeActions">
|
<Section className="App-mobile-menu" heading="selectedShapeActions">
|
||||||
<SelectedShapeActions
|
<SelectedShapeActions
|
||||||
appState={appState}
|
appState={appState}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ const ChartPreviewBtn = (props: {
|
|||||||
},
|
},
|
||||||
null, // files
|
null, // files
|
||||||
);
|
);
|
||||||
|
svg.querySelector(".style-fonts")?.remove();
|
||||||
previewNode.replaceChildren();
|
previewNode.replaceChildren();
|
||||||
previewNode.appendChild(svg);
|
previewNode.appendChild(svg);
|
||||||
|
|
||||||
|
|||||||
@@ -3,24 +3,6 @@
|
|||||||
|
|
||||||
.excalidraw {
|
.excalidraw {
|
||||||
.Sidebar {
|
.Sidebar {
|
||||||
&__dropdown-content {
|
|
||||||
z-index: 1;
|
|
||||||
position: absolute;
|
|
||||||
top: 100%;
|
|
||||||
left: 0;
|
|
||||||
|
|
||||||
:root[dir="rtl"] & {
|
|
||||||
right: 0;
|
|
||||||
left: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
margin-top: 0.25rem;
|
|
||||||
width: 180px;
|
|
||||||
box-shadow: var(--library-dropdown-shadow);
|
|
||||||
border-radius: var(--border-radius-lg);
|
|
||||||
padding: 0.25rem 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__close-btn,
|
&__close-btn,
|
||||||
&__pin-btn,
|
&__pin-btn,
|
||||||
&__dropdown-btn {
|
&__dropdown-btn {
|
||||||
|
|||||||
@@ -90,10 +90,10 @@ describe("Sidebar", () => {
|
|||||||
|
|
||||||
const sidebar = container.querySelector<HTMLElement>(".test-sidebar");
|
const sidebar = container.querySelector<HTMLElement>(".test-sidebar");
|
||||||
expect(sidebar).not.toBe(null);
|
expect(sidebar).not.toBe(null);
|
||||||
const closeButton = queryByTestId(sidebar!, "sidebar-close");
|
const closeButton = queryByTestId(sidebar!, "sidebar-close")!;
|
||||||
expect(closeButton).not.toBe(null);
|
expect(closeButton).not.toBe(null);
|
||||||
|
|
||||||
fireEvent.click(closeButton!.querySelector("button")!);
|
fireEvent.click(closeButton);
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(container.querySelector<HTMLElement>(".test-sidebar")).toBe(null);
|
expect(container.querySelector<HTMLElement>(".test-sidebar")).toBe(null);
|
||||||
expect(onClose).toHaveBeenCalled();
|
expect(onClose).toHaveBeenCalled();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
|
align-items: center;
|
||||||
gap: 0.625rem;
|
gap: 0.625rem;
|
||||||
|
|
||||||
&:empty {
|
&:empty {
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ import React from "react";
|
|||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { AppState, Collaborator } from "../types";
|
import { AppState, Collaborator } from "../types";
|
||||||
import { Tooltip } from "./Tooltip";
|
import { Tooltip } from "./Tooltip";
|
||||||
import { ActionManager } from "../actions/manager";
|
import { useExcalidrawActionManager } from "./App";
|
||||||
|
|
||||||
export const UserList: React.FC<{
|
export const UserList: React.FC<{
|
||||||
className?: string;
|
className?: string;
|
||||||
mobile?: boolean;
|
mobile?: boolean;
|
||||||
collaborators: AppState["collaborators"];
|
collaborators: AppState["collaborators"];
|
||||||
actionManager: ActionManager;
|
}> = ({ className, mobile, collaborators }) => {
|
||||||
}> = ({ className, mobile, collaborators, actionManager }) => {
|
const actionManager = useExcalidrawActionManager();
|
||||||
const uniqueCollaborators = new Map<string, Collaborator>();
|
|
||||||
|
|
||||||
|
const uniqueCollaborators = new Map<string, Collaborator>();
|
||||||
collaborators.forEach((collaborator, socketId) => {
|
collaborators.forEach((collaborator, socketId) => {
|
||||||
uniqueCollaborators.set(
|
uniqueCollaborators.set(
|
||||||
// filter on user id, else fall back on unique socketId
|
// filter on user id, else fall back on unique socketId
|
||||||
@@ -44,26 +44,6 @@ export const UserList: React.FC<{
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO barnabasmolnar/editor-redesign
|
|
||||||
// probably remove before shipping :)
|
|
||||||
// 20 fake collaborators; for easy, convenient debug purposes ˇˇ
|
|
||||||
// const avatars = Array.from({ length: 20 }).map((_, index) => {
|
|
||||||
// const avatarJSX = actionManager.renderAction("goToCollaborator", [
|
|
||||||
// index.toString(),
|
|
||||||
// {
|
|
||||||
// username: `User ${index}`,
|
|
||||||
// },
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
// return mobile ? (
|
|
||||||
// <Tooltip label={`User ${index}`} key={index}>
|
|
||||||
// {avatarJSX}
|
|
||||||
// </Tooltip>
|
|
||||||
// ) : (
|
|
||||||
// <React.Fragment key={index}>{avatarJSX}</React.Fragment>
|
|
||||||
// );
|
|
||||||
// });
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx("UserList", className, { UserList_mobile: mobile })}>
|
<div className={clsx("UserList", className, { UserList_mobile: mobile })}>
|
||||||
{avatars}
|
{avatars}
|
||||||
|
|||||||
@@ -1,141 +0,0 @@
|
|||||||
import { useAtom } from "jotai";
|
|
||||||
import { actionLoadScene, actionShortcuts } from "../actions";
|
|
||||||
import { ActionManager } from "../actions/manager";
|
|
||||||
import { getShortcutFromShortcutName } from "../actions/shortcuts";
|
|
||||||
import { COOKIES } from "../constants";
|
|
||||||
import { collabDialogShownAtom } from "../excalidraw-app/collab/Collab";
|
|
||||||
import { t } from "../i18n";
|
|
||||||
import { AppState } from "../types";
|
|
||||||
import {
|
|
||||||
ExcalLogo,
|
|
||||||
HelpIcon,
|
|
||||||
LoadIcon,
|
|
||||||
PlusPromoIcon,
|
|
||||||
UsersIcon,
|
|
||||||
} from "./icons";
|
|
||||||
import "./WelcomeScreen.scss";
|
|
||||||
|
|
||||||
const isExcalidrawPlusSignedUser = document.cookie.includes(
|
|
||||||
COOKIES.AUTH_STATE_COOKIE,
|
|
||||||
);
|
|
||||||
|
|
||||||
const WelcomeScreenItem = ({
|
|
||||||
label,
|
|
||||||
shortcut,
|
|
||||||
onClick,
|
|
||||||
icon,
|
|
||||||
link,
|
|
||||||
}: {
|
|
||||||
label: string;
|
|
||||||
shortcut: string | null;
|
|
||||||
onClick?: () => void;
|
|
||||||
icon: JSX.Element;
|
|
||||||
link?: string;
|
|
||||||
}) => {
|
|
||||||
if (link) {
|
|
||||||
return (
|
|
||||||
<a
|
|
||||||
className="WelcomeScreen-item"
|
|
||||||
href={link}
|
|
||||||
target="_blank"
|
|
||||||
rel="noreferrer"
|
|
||||||
>
|
|
||||||
<div className="WelcomeScreen-item__label">
|
|
||||||
{icon}
|
|
||||||
{label}
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<button className="WelcomeScreen-item" type="button" onClick={onClick}>
|
|
||||||
<div className="WelcomeScreen-item__label">
|
|
||||||
{icon}
|
|
||||||
{label}
|
|
||||||
</div>
|
|
||||||
{shortcut && (
|
|
||||||
<div className="WelcomeScreen-item__shortcut">{shortcut}</div>
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const WelcomeScreen = ({
|
|
||||||
appState,
|
|
||||||
actionManager,
|
|
||||||
}: {
|
|
||||||
appState: AppState;
|
|
||||||
actionManager: ActionManager;
|
|
||||||
}) => {
|
|
||||||
const [, setCollabDialogShown] = useAtom(collabDialogShownAtom);
|
|
||||||
|
|
||||||
let subheadingJSX;
|
|
||||||
|
|
||||||
if (isExcalidrawPlusSignedUser) {
|
|
||||||
subheadingJSX = t("welcomeScreen.switchToPlusApp")
|
|
||||||
.split(/(Excalidraw\+)/)
|
|
||||||
.map((bit, idx) => {
|
|
||||||
if (bit === "Excalidraw+") {
|
|
||||||
return (
|
|
||||||
<a
|
|
||||||
style={{ pointerEvents: "all" }}
|
|
||||||
href={`${process.env.REACT_APP_PLUS_APP}?utm_source=excalidraw&utm_medium=app&utm_content=welcomeScreenSignedInUser`}
|
|
||||||
key={idx}
|
|
||||||
>
|
|
||||||
Excalidraw+
|
|
||||||
</a>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return bit;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
subheadingJSX = t("welcomeScreen.data");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="WelcomeScreen-container">
|
|
||||||
<div className="WelcomeScreen-logo virgil WelcomeScreen-decor">
|
|
||||||
{ExcalLogo} Excalidraw
|
|
||||||
</div>
|
|
||||||
<div className="virgil WelcomeScreen-decor WelcomeScreen-decor--subheading">
|
|
||||||
{subheadingJSX}
|
|
||||||
</div>
|
|
||||||
<div className="WelcomeScreen-items">
|
|
||||||
{!appState.viewModeEnabled && (
|
|
||||||
<WelcomeScreenItem
|
|
||||||
// TODO barnabasmolnar/editor-redesign
|
|
||||||
// do we want the internationalized labels here that are currently
|
|
||||||
// in use elsewhere or new ones?
|
|
||||||
label={t("buttons.load")}
|
|
||||||
onClick={() => actionManager.executeAction(actionLoadScene)}
|
|
||||||
shortcut={getShortcutFromShortcutName("loadScene")}
|
|
||||||
icon={LoadIcon}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<WelcomeScreenItem
|
|
||||||
label={t("labels.liveCollaboration")}
|
|
||||||
shortcut={null}
|
|
||||||
onClick={() => setCollabDialogShown(true)}
|
|
||||||
icon={UsersIcon}
|
|
||||||
/>
|
|
||||||
<WelcomeScreenItem
|
|
||||||
onClick={() => actionManager.executeAction(actionShortcuts)}
|
|
||||||
label={t("helpDialog.title")}
|
|
||||||
shortcut="?"
|
|
||||||
icon={HelpIcon}
|
|
||||||
/>
|
|
||||||
{!isExcalidrawPlusSignedUser && (
|
|
||||||
<WelcomeScreenItem
|
|
||||||
link="https://plus.excalidraw.com/plus?utm_source=excalidraw&utm_medium=app&utm_content=welcomeScreenGuest"
|
|
||||||
label="Try Excalidraw Plus!"
|
|
||||||
shortcut={null}
|
|
||||||
icon={PlusPromoIcon}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default WelcomeScreen;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { ReactNode } from "react";
|
|
||||||
|
|
||||||
const WelcomeScreenDecor = ({
|
|
||||||
children,
|
|
||||||
shouldRender,
|
|
||||||
}: {
|
|
||||||
children: ReactNode;
|
|
||||||
shouldRender: boolean;
|
|
||||||
}) => (shouldRender ? <>{children}</> : null);
|
|
||||||
|
|
||||||
export default WelcomeScreenDecor;
|
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
@import "../../css/variables.module";
|
||||||
|
|
||||||
|
.excalidraw {
|
||||||
|
.dropdown-menu {
|
||||||
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
margin-top: 0.25rem;
|
||||||
|
|
||||||
|
&--mobile {
|
||||||
|
bottom: 55px;
|
||||||
|
top: auto;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
row-gap: 0.75rem;
|
||||||
|
|
||||||
|
.dropdown-menu-container {
|
||||||
|
padding: 8px 8px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background-color: var(--island-bg-color);
|
||||||
|
box-shadow: var(--shadow-island);
|
||||||
|
border-radius: var(--border-radius-lg);
|
||||||
|
position: relative;
|
||||||
|
transition: box-shadow 0.5s ease-in-out;
|
||||||
|
|
||||||
|
&.zen-mode {
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu-container {
|
||||||
|
background-color: #fff !important;
|
||||||
|
max-height: calc(100vh - 150px);
|
||||||
|
overflow-y: auto;
|
||||||
|
--gap: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu-item-base {
|
||||||
|
display: flex;
|
||||||
|
padding: 0 0.625rem;
|
||||||
|
column-gap: 0.625rem;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
color: var(--color-gray-100);
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-weight: normal;
|
||||||
|
font-family: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu-item {
|
||||||
|
background-color: transparent;
|
||||||
|
border: 0;
|
||||||
|
align-items: center;
|
||||||
|
height: 2rem;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: var(--border-radius-md);
|
||||||
|
|
||||||
|
@media screen and (min-width: 1921px) {
|
||||||
|
height: 2.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__text {
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__shortcut {
|
||||||
|
margin-inline-start: auto;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--button-hover-bg);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: 1rem;
|
||||||
|
height: 1rem;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu-item-custom {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu-group-title {
|
||||||
|
font-size: 14px;
|
||||||
|
text-align: left;
|
||||||
|
margin: 10px 0;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.theme--dark {
|
||||||
|
.dropdown-menu-item {
|
||||||
|
color: var(--color-gray-40);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu-container {
|
||||||
|
background-color: var(--color-gray-90) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu-button {
|
||||||
|
@include outlineButtonStyles;
|
||||||
|
background-color: var(--island-bg-color);
|
||||||
|
width: var(--lg-button-size);
|
||||||
|
height: var(--lg-button-size);
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: var(--lg-icon-size);
|
||||||
|
height: var(--lg-icon-size);
|
||||||
|
}
|
||||||
|
|
||||||
|
&--mobile {
|
||||||
|
border: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: var(--default-button-size);
|
||||||
|
height: var(--default-button-size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import React from "react";
|
||||||
|
import DropdownMenuTrigger from "./DropdownMenuTrigger";
|
||||||
|
import DropdownMenuItem from "./DropdownMenuItem";
|
||||||
|
import MenuSeparator from "./DropdownMenuSeparator";
|
||||||
|
import DropdownMenuGroup from "./DropdownMenuGroup";
|
||||||
|
import DropdownMenuContent from "./DropdownMenuContent";
|
||||||
|
import DropdownMenuItemLink from "./DropdownMenuItemLink";
|
||||||
|
import DropdownMenuItemCustom from "./DropdownMenuItemCustom";
|
||||||
|
import {
|
||||||
|
getMenuContentComponent,
|
||||||
|
getMenuTriggerComponent,
|
||||||
|
} from "./dropdownMenuUtils";
|
||||||
|
|
||||||
|
import "./DropdownMenu.scss";
|
||||||
|
|
||||||
|
const DropdownMenu = ({
|
||||||
|
children,
|
||||||
|
open,
|
||||||
|
}: {
|
||||||
|
children?: React.ReactNode;
|
||||||
|
open: boolean;
|
||||||
|
}) => {
|
||||||
|
const MenuTriggerComp = getMenuTriggerComponent(children);
|
||||||
|
const MenuContentComp = getMenuContentComponent(children);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{MenuTriggerComp}
|
||||||
|
{open && MenuContentComp}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
DropdownMenu.Trigger = DropdownMenuTrigger;
|
||||||
|
DropdownMenu.Content = DropdownMenuContent;
|
||||||
|
DropdownMenu.Item = DropdownMenuItem;
|
||||||
|
DropdownMenu.ItemLink = DropdownMenuItemLink;
|
||||||
|
DropdownMenu.ItemCustom = DropdownMenuItemCustom;
|
||||||
|
DropdownMenu.Group = DropdownMenuGroup;
|
||||||
|
DropdownMenu.Separator = MenuSeparator;
|
||||||
|
|
||||||
|
export default DropdownMenu;
|
||||||
|
|
||||||
|
DropdownMenu.displayName = "DropdownMenu";
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { useOutsideClickHook } from "../../hooks/useOutsideClick";
|
||||||
|
import { Island } from "../Island";
|
||||||
|
|
||||||
|
import { useDevice } from "../App";
|
||||||
|
import clsx from "clsx";
|
||||||
|
import Stack from "../Stack";
|
||||||
|
|
||||||
|
const MenuContent = ({
|
||||||
|
children,
|
||||||
|
onClickOutside,
|
||||||
|
className = "",
|
||||||
|
style,
|
||||||
|
}: {
|
||||||
|
children?: React.ReactNode;
|
||||||
|
onClickOutside?: () => void;
|
||||||
|
className?: string;
|
||||||
|
style?: React.CSSProperties;
|
||||||
|
}) => {
|
||||||
|
const device = useDevice();
|
||||||
|
const menuRef = useOutsideClickHook(() => {
|
||||||
|
onClickOutside?.();
|
||||||
|
});
|
||||||
|
|
||||||
|
const classNames = clsx(`dropdown-menu ${className}`, {
|
||||||
|
"dropdown-menu--mobile": device.isMobile,
|
||||||
|
}).trim();
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={menuRef}
|
||||||
|
className={classNames}
|
||||||
|
style={style}
|
||||||
|
data-testid="dropdown-menu"
|
||||||
|
>
|
||||||
|
{/* the zIndex ensures this menu has higher stacking order,
|
||||||
|
see https://github.com/excalidraw/excalidraw/pull/1445 */}
|
||||||
|
{device.isMobile ? (
|
||||||
|
<Stack.Col className="dropdown-menu-container">{children}</Stack.Col>
|
||||||
|
) : (
|
||||||
|
<Island
|
||||||
|
className="dropdown-menu-container"
|
||||||
|
padding={2}
|
||||||
|
style={{ zIndex: 1 }}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Island>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default MenuContent;
|
||||||
|
MenuContent.displayName = "DropdownMenuContent";
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const MenuGroup = ({
|
||||||
|
children,
|
||||||
|
className = "",
|
||||||
|
style,
|
||||||
|
title,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
className?: string;
|
||||||
|
style?: React.CSSProperties;
|
||||||
|
title?: string;
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<div className={`dropdown-menu-group ${className}`} style={style}>
|
||||||
|
{title && <p className="dropdown-menu-group-title">{title}</p>}
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MenuGroup;
|
||||||
|
MenuGroup.displayName = "DropdownMenuGroup";
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import React from "react";
|
||||||
|
import MenuItemContent from "./DropdownMenuItemContent";
|
||||||
|
|
||||||
|
export const getDrodownMenuItemClassName = (className = "") => {
|
||||||
|
return `dropdown-menu-item dropdown-menu-item-base ${className}`.trim();
|
||||||
|
};
|
||||||
|
|
||||||
|
const DropdownMenuItem = ({
|
||||||
|
icon,
|
||||||
|
onSelect,
|
||||||
|
children,
|
||||||
|
shortcut,
|
||||||
|
className,
|
||||||
|
...rest
|
||||||
|
}: {
|
||||||
|
icon?: JSX.Element;
|
||||||
|
onSelect: () => void;
|
||||||
|
children: React.ReactNode;
|
||||||
|
shortcut?: string;
|
||||||
|
className?: string;
|
||||||
|
} & React.ButtonHTMLAttributes<HTMLButtonElement>) => {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
{...rest}
|
||||||
|
onClick={onSelect}
|
||||||
|
type="button"
|
||||||
|
className={getDrodownMenuItemClassName(className)}
|
||||||
|
title={rest.title ?? rest["aria-label"]}
|
||||||
|
>
|
||||||
|
<MenuItemContent icon={icon} shortcut={shortcut}>
|
||||||
|
{children}
|
||||||
|
</MenuItemContent>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DropdownMenuItem;
|
||||||
|
DropdownMenuItem.displayName = "DropdownMenuItem";
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { useDevice } from "../App";
|
||||||
|
|
||||||
|
const MenuItemContent = ({
|
||||||
|
icon,
|
||||||
|
shortcut,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
icon?: JSX.Element;
|
||||||
|
shortcut?: string;
|
||||||
|
children: React.ReactNode;
|
||||||
|
}) => {
|
||||||
|
const device = useDevice();
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="dropdown-menu-item__icon">{icon}</div>
|
||||||
|
<div className="dropdown-menu-item__text">{children}</div>
|
||||||
|
{shortcut && !device.isMobile && (
|
||||||
|
<div className="dropdown-menu-item__shortcut">{shortcut}</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
export default MenuItemContent;
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const DropdownMenuItemCustom = ({
|
||||||
|
children,
|
||||||
|
className = "",
|
||||||
|
...rest
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
className?: string;
|
||||||
|
} & React.HTMLAttributes<HTMLDivElement>) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
{...rest}
|
||||||
|
className={`dropdown-menu-item-base dropdown-menu-item-custom ${className}`.trim()}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DropdownMenuItemCustom;
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import MenuItemContent from "./DropdownMenuItemContent";
|
||||||
|
import React from "react";
|
||||||
|
import { getDrodownMenuItemClassName } from "./DropdownMenuItem";
|
||||||
|
const DropdownMenuItemLink = ({
|
||||||
|
icon,
|
||||||
|
shortcut,
|
||||||
|
href,
|
||||||
|
children,
|
||||||
|
className = "",
|
||||||
|
...rest
|
||||||
|
}: {
|
||||||
|
icon?: JSX.Element;
|
||||||
|
children: React.ReactNode;
|
||||||
|
shortcut?: string;
|
||||||
|
className?: string;
|
||||||
|
href: string;
|
||||||
|
} & React.AnchorHTMLAttributes<HTMLAnchorElement>) => {
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
{...rest}
|
||||||
|
href={href}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
className={getDrodownMenuItemClassName(className)}
|
||||||
|
title={rest.title ?? rest["aria-label"]}
|
||||||
|
>
|
||||||
|
<MenuItemContent icon={icon} shortcut={shortcut}>
|
||||||
|
{children}
|
||||||
|
</MenuItemContent>
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DropdownMenuItemLink;
|
||||||
|
DropdownMenuItemLink.displayName = "DropdownMenuItemLink";
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const MenuSeparator = () => (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: "1px",
|
||||||
|
backgroundColor: "var(--default-border-color)",
|
||||||
|
margin: ".5rem 0",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default MenuSeparator;
|
||||||
|
MenuSeparator.displayName = "DropdownMenuSeparator";
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import clsx from "clsx";
|
||||||
|
import { useDevice, useExcalidrawAppState } from "../App";
|
||||||
|
|
||||||
|
const MenuTrigger = ({
|
||||||
|
className = "",
|
||||||
|
children,
|
||||||
|
onToggle,
|
||||||
|
}: {
|
||||||
|
className?: string;
|
||||||
|
children: React.ReactNode;
|
||||||
|
onToggle: () => void;
|
||||||
|
}) => {
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
const device = useDevice();
|
||||||
|
const classNames = clsx(
|
||||||
|
`dropdown-menu-button ${className}`,
|
||||||
|
"zen-mode-transition",
|
||||||
|
{
|
||||||
|
"transition-left": appState.zenModeEnabled,
|
||||||
|
"dropdown-menu-button--mobile": device.isMobile,
|
||||||
|
},
|
||||||
|
).trim();
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
data-prevent-outside-click
|
||||||
|
className={classNames}
|
||||||
|
onClick={onToggle}
|
||||||
|
type="button"
|
||||||
|
data-testid="dropdown-menu-button"
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MenuTrigger;
|
||||||
|
MenuTrigger.displayName = "DropdownMenuTrigger";
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export const getMenuTriggerComponent = (children: React.ReactNode) => {
|
||||||
|
const comp = React.Children.toArray(children).find(
|
||||||
|
(child) =>
|
||||||
|
React.isValidElement(child) &&
|
||||||
|
typeof child.type !== "string" &&
|
||||||
|
//@ts-ignore
|
||||||
|
child?.type.displayName &&
|
||||||
|
//@ts-ignore
|
||||||
|
child.type.displayName === "DropdownMenuTrigger",
|
||||||
|
);
|
||||||
|
if (!comp) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
//@ts-ignore
|
||||||
|
return comp;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getMenuContentComponent = (children: React.ReactNode) => {
|
||||||
|
const comp = React.Children.toArray(children).find(
|
||||||
|
(child) =>
|
||||||
|
React.isValidElement(child) &&
|
||||||
|
typeof child.type !== "string" &&
|
||||||
|
//@ts-ignore
|
||||||
|
child?.type.displayName &&
|
||||||
|
//@ts-ignore
|
||||||
|
child.type.displayName === "DropdownMenuContent",
|
||||||
|
);
|
||||||
|
if (!comp) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
//@ts-ignore
|
||||||
|
return comp;
|
||||||
|
};
|
||||||
@@ -1,35 +1,39 @@
|
|||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { ActionManager } from "../actions/manager";
|
import { actionShortcuts } from "../../actions";
|
||||||
import { t } from "../i18n";
|
import { ActionManager } from "../../actions/manager";
|
||||||
import { AppState, ExcalidrawProps } from "../types";
|
import {
|
||||||
|
AppState,
|
||||||
|
UIChildrenComponents,
|
||||||
|
UIWelcomeScreenComponents,
|
||||||
|
} from "../../types";
|
||||||
import {
|
import {
|
||||||
ExitZenModeAction,
|
ExitZenModeAction,
|
||||||
FinalizeAction,
|
FinalizeAction,
|
||||||
UndoRedoActions,
|
UndoRedoActions,
|
||||||
ZoomActions,
|
ZoomActions,
|
||||||
} from "./Actions";
|
} from "../Actions";
|
||||||
import { useDevice } from "./App";
|
import { useDevice } from "../App";
|
||||||
import { WelcomeScreenHelpArrow } from "./icons";
|
import { HelpButton } from "../HelpButton";
|
||||||
import { Section } from "./Section";
|
import { Section } from "../Section";
|
||||||
import Stack from "./Stack";
|
import Stack from "../Stack";
|
||||||
import WelcomeScreenDecor from "./WelcomeScreenDecor";
|
|
||||||
|
|
||||||
const Footer = ({
|
const Footer = ({
|
||||||
appState,
|
appState,
|
||||||
actionManager,
|
actionManager,
|
||||||
renderCustomFooter,
|
|
||||||
showExitZenModeBtn,
|
showExitZenModeBtn,
|
||||||
renderWelcomeScreen,
|
footerCenter,
|
||||||
|
welcomeScreenHelp,
|
||||||
}: {
|
}: {
|
||||||
appState: AppState;
|
appState: AppState;
|
||||||
actionManager: ActionManager;
|
actionManager: ActionManager;
|
||||||
renderCustomFooter?: ExcalidrawProps["renderFooter"];
|
|
||||||
showExitZenModeBtn: boolean;
|
showExitZenModeBtn: boolean;
|
||||||
renderWelcomeScreen: boolean;
|
footerCenter: UIChildrenComponents["FooterCenter"];
|
||||||
|
welcomeScreenHelp: UIWelcomeScreenComponents["HelpHint"];
|
||||||
}) => {
|
}) => {
|
||||||
const device = useDevice();
|
const device = useDevice();
|
||||||
const showFinalize =
|
const showFinalize =
|
||||||
!appState.viewModeEnabled && appState.multiElement && device.isTouchScreen;
|
!appState.viewModeEnabled && appState.multiElement && device.isTouchScreen;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<footer
|
<footer
|
||||||
role="contentinfo"
|
role="contentinfo"
|
||||||
@@ -69,33 +73,17 @@ const Footer = ({
|
|||||||
</Section>
|
</Section>
|
||||||
</Stack.Col>
|
</Stack.Col>
|
||||||
</div>
|
</div>
|
||||||
<div
|
{footerCenter}
|
||||||
className={clsx(
|
|
||||||
"layer-ui__wrapper__footer-center zen-mode-transition",
|
|
||||||
{
|
|
||||||
"layer-ui__wrapper__footer-left--transition-bottom":
|
|
||||||
appState.zenModeEnabled,
|
|
||||||
},
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{renderCustomFooter?.(false, appState)}
|
|
||||||
</div>
|
|
||||||
<div
|
<div
|
||||||
className={clsx("layer-ui__wrapper__footer-right zen-mode-transition", {
|
className={clsx("layer-ui__wrapper__footer-right zen-mode-transition", {
|
||||||
"transition-right disable-pointerEvents": appState.zenModeEnabled,
|
"transition-right disable-pointerEvents": appState.zenModeEnabled,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div style={{ position: "relative" }}>
|
<div style={{ position: "relative" }}>
|
||||||
<WelcomeScreenDecor
|
{welcomeScreenHelp}
|
||||||
shouldRender={renderWelcomeScreen && !appState.isLoading}
|
<HelpButton
|
||||||
>
|
onClick={() => actionManager.executeAction(actionShortcuts)}
|
||||||
<div className="virgil WelcomeScreen-decor WelcomeScreen-decor--help-pointer">
|
/>
|
||||||
<div>{t("welcomeScreen.helpHints")}</div>
|
|
||||||
{WelcomeScreenHelpArrow}
|
|
||||||
</div>
|
|
||||||
</WelcomeScreenDecor>
|
|
||||||
|
|
||||||
{actionManager.renderAction("toggleShortcuts")}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ExitZenModeAction
|
<ExitZenModeAction
|
||||||
@@ -107,3 +95,4 @@ const Footer = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default Footer;
|
export default Footer;
|
||||||
|
Footer.displayName = "Footer";
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
.footer-center {
|
||||||
|
pointer-events: none;
|
||||||
|
& > * {
|
||||||
|
pointer-events: all;
|
||||||
|
}
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import clsx from "clsx";
|
||||||
|
import { useExcalidrawAppState } from "../App";
|
||||||
|
import "./FooterCenter.scss";
|
||||||
|
|
||||||
|
const FooterCenter = ({ children }: { children?: React.ReactNode }) => {
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={clsx("footer-center zen-mode-transition", {
|
||||||
|
"layer-ui__wrapper__footer-left--transition-bottom":
|
||||||
|
appState.zenModeEnabled,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default FooterCenter;
|
||||||
|
FooterCenter.displayName = "FooterCenter";
|
||||||
+10
-10
@@ -883,7 +883,7 @@ export const CenterHorizontallyIcon = createIcon(
|
|||||||
modifiedTablerIconProps,
|
modifiedTablerIconProps,
|
||||||
);
|
);
|
||||||
|
|
||||||
export const UsersIcon = createIcon(
|
export const usersIcon = createIcon(
|
||||||
<g strokeWidth="1.5">
|
<g strokeWidth="1.5">
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||||
<circle cx="9" cy="7" r="4"></circle>
|
<circle cx="9" cy="7" r="4"></circle>
|
||||||
@@ -1470,11 +1470,11 @@ export const TextAlignRightIcon = createIcon(
|
|||||||
export const TextAlignTopIcon = React.memo(({ theme }: { theme: Theme }) =>
|
export const TextAlignTopIcon = React.memo(({ theme }: { theme: Theme }) =>
|
||||||
createIcon(
|
createIcon(
|
||||||
<g
|
<g
|
||||||
stroke-width="1.5"
|
strokeWidth="1.5"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke-linecap="round"
|
strokeLinecap="round"
|
||||||
stroke-linejoin="round"
|
strokeLinejoin="round"
|
||||||
>
|
>
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
<line x1="4" y1="4" x2="20" y2="4" />
|
<line x1="4" y1="4" x2="20" y2="4" />
|
||||||
@@ -1488,11 +1488,11 @@ export const TextAlignTopIcon = React.memo(({ theme }: { theme: Theme }) =>
|
|||||||
export const TextAlignBottomIcon = React.memo(({ theme }: { theme: Theme }) =>
|
export const TextAlignBottomIcon = React.memo(({ theme }: { theme: Theme }) =>
|
||||||
createIcon(
|
createIcon(
|
||||||
<g
|
<g
|
||||||
stroke-width="2"
|
strokeWidth="2"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke-linecap="round"
|
strokeLinecap="round"
|
||||||
stroke-linejoin="round"
|
strokeLinejoin="round"
|
||||||
>
|
>
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
<line x1="4" y1="20" x2="20" y2="20" />
|
<line x1="4" y1="20" x2="20" y2="20" />
|
||||||
@@ -1506,11 +1506,11 @@ export const TextAlignBottomIcon = React.memo(({ theme }: { theme: Theme }) =>
|
|||||||
export const TextAlignMiddleIcon = React.memo(({ theme }: { theme: Theme }) =>
|
export const TextAlignMiddleIcon = React.memo(({ theme }: { theme: Theme }) =>
|
||||||
createIcon(
|
createIcon(
|
||||||
<g
|
<g
|
||||||
stroke-width="1.5"
|
strokeWidth="1.5"
|
||||||
stroke="currentColor"
|
stroke="currentColor"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke-linecap="round"
|
strokeLinecap="round"
|
||||||
stroke-linejoin="round"
|
strokeLinejoin="round"
|
||||||
>
|
>
|
||||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||||
<line x1="4" y1="12" x2="9" y2="12" />
|
<line x1="4" y1="12" x2="9" y2="12" />
|
||||||
|
|||||||
+14
-21
@@ -1,30 +1,23 @@
|
|||||||
@import "../css/variables.module";
|
@import "../../css/variables.module";
|
||||||
|
|
||||||
.excalidraw {
|
.excalidraw {
|
||||||
.collab-button {
|
.collab-button {
|
||||||
@include outlineButtonStyles;
|
--button-bg: var(--color-primary);
|
||||||
width: var(--lg-button-size);
|
--button-color: white;
|
||||||
height: var(--lg-button-size);
|
--button-border: var(--color-primary);
|
||||||
|
|
||||||
|
--button-width: var(--lg-button-size);
|
||||||
|
--button-height: var(--lg-button-size);
|
||||||
|
|
||||||
|
--button-hover-bg: var(--color-primary-darker);
|
||||||
|
--button-hover-border: var(--color-primary-darker);
|
||||||
|
|
||||||
|
--button-active-bg: var(--color-primary-darker);
|
||||||
|
|
||||||
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;
|
flex-shrink: 0;
|
||||||
|
|
||||||
&:hover {
|
// double .active to force specificity
|
||||||
background-color: var(--color-primary-darker);
|
&.active.active {
|
||||||
border-color: var(--color-primary-darker);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active {
|
|
||||||
background-color: var(--color-primary-darker);
|
|
||||||
}
|
|
||||||
|
|
||||||
&.active {
|
|
||||||
background-color: #0fb884;
|
background-color: #0fb884;
|
||||||
border-color: #0fb884;
|
border-color: #0fb884;
|
||||||
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { t } from "../../i18n";
|
||||||
|
import { usersIcon } from "../icons";
|
||||||
|
import { Button } from "../Button";
|
||||||
|
|
||||||
|
import clsx from "clsx";
|
||||||
|
import { useExcalidrawAppState } from "../App";
|
||||||
|
|
||||||
|
import "./LiveCollaborationTrigger.scss";
|
||||||
|
|
||||||
|
const LiveCollaborationTrigger = ({
|
||||||
|
isCollaborating,
|
||||||
|
onSelect,
|
||||||
|
...rest
|
||||||
|
}: {
|
||||||
|
isCollaborating: boolean;
|
||||||
|
onSelect: () => void;
|
||||||
|
} & React.ButtonHTMLAttributes<HTMLButtonElement>) => {
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
{...rest}
|
||||||
|
className={clsx("collab-button", { active: isCollaborating })}
|
||||||
|
type="button"
|
||||||
|
onSelect={onSelect}
|
||||||
|
style={{ position: "relative" }}
|
||||||
|
title={t("labels.liveCollaboration")}
|
||||||
|
>
|
||||||
|
{usersIcon}
|
||||||
|
{appState.collaborators.size > 0 && (
|
||||||
|
<div className="CollabButton-collaborators">
|
||||||
|
{appState.collaborators.size}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LiveCollaborationTrigger;
|
||||||
|
LiveCollaborationTrigger.displayName = "LiveCollaborationTrigger";
|
||||||
@@ -0,0 +1,285 @@
|
|||||||
|
import { getShortcutFromShortcutName } from "../../actions/shortcuts";
|
||||||
|
import { t } from "../../i18n";
|
||||||
|
import {
|
||||||
|
useExcalidrawAppState,
|
||||||
|
useExcalidrawSetAppState,
|
||||||
|
useExcalidrawActionManager,
|
||||||
|
} from "../App";
|
||||||
|
import {
|
||||||
|
ExportIcon,
|
||||||
|
ExportImageIcon,
|
||||||
|
HelpIcon,
|
||||||
|
LoadIcon,
|
||||||
|
MoonIcon,
|
||||||
|
save,
|
||||||
|
SunIcon,
|
||||||
|
TrashIcon,
|
||||||
|
usersIcon,
|
||||||
|
} from "../icons";
|
||||||
|
import { GithubIcon, DiscordIcon, TwitterIcon } from "../icons";
|
||||||
|
import DropdownMenuItem from "../dropdownMenu/DropdownMenuItem";
|
||||||
|
import DropdownMenuItemLink from "../dropdownMenu/DropdownMenuItemLink";
|
||||||
|
import {
|
||||||
|
actionClearCanvas,
|
||||||
|
actionLoadScene,
|
||||||
|
actionSaveToActiveFile,
|
||||||
|
actionShortcuts,
|
||||||
|
actionToggleTheme,
|
||||||
|
} from "../../actions";
|
||||||
|
|
||||||
|
import "./DefaultItems.scss";
|
||||||
|
import { useState } from "react";
|
||||||
|
import ConfirmDialog from "../ConfirmDialog";
|
||||||
|
import clsx from "clsx";
|
||||||
|
|
||||||
|
export const LoadScene = () => {
|
||||||
|
// FIXME Hack until we tie "t" to lang state
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
const actionManager = useExcalidrawActionManager();
|
||||||
|
|
||||||
|
if (!actionManager.isActionEnabled(actionLoadScene)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DropdownMenuItem
|
||||||
|
icon={LoadIcon}
|
||||||
|
onSelect={() => actionManager.executeAction(actionLoadScene)}
|
||||||
|
data-testid="load-button"
|
||||||
|
shortcut={getShortcutFromShortcutName("loadScene")}
|
||||||
|
aria-label={t("buttons.load")}
|
||||||
|
>
|
||||||
|
{t("buttons.load")}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
LoadScene.displayName = "LoadScene";
|
||||||
|
|
||||||
|
export const SaveToActiveFile = () => {
|
||||||
|
// FIXME Hack until we tie "t" to lang state
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
const actionManager = useExcalidrawActionManager();
|
||||||
|
|
||||||
|
if (!actionManager.isActionEnabled(actionSaveToActiveFile)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DropdownMenuItem
|
||||||
|
shortcut={getShortcutFromShortcutName("saveScene")}
|
||||||
|
data-testid="save-button"
|
||||||
|
onSelect={() => actionManager.executeAction(actionSaveToActiveFile)}
|
||||||
|
icon={save}
|
||||||
|
aria-label={`${t("buttons.save")}`}
|
||||||
|
>{`${t("buttons.save")}`}</DropdownMenuItem>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
SaveToActiveFile.displayName = "SaveToActiveFile";
|
||||||
|
|
||||||
|
export const SaveAsImage = () => {
|
||||||
|
const setAppState = useExcalidrawSetAppState();
|
||||||
|
// FIXME Hack until we tie "t" to lang state
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
return (
|
||||||
|
<DropdownMenuItem
|
||||||
|
icon={ExportImageIcon}
|
||||||
|
data-testid="image-export-button"
|
||||||
|
onSelect={() => setAppState({ openDialog: "imageExport" })}
|
||||||
|
shortcut={getShortcutFromShortcutName("imageExport")}
|
||||||
|
aria-label={t("buttons.exportImage")}
|
||||||
|
>
|
||||||
|
{t("buttons.exportImage")}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
SaveAsImage.displayName = "SaveAsImage";
|
||||||
|
|
||||||
|
export const Help = () => {
|
||||||
|
// FIXME Hack until we tie "t" to lang state
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
|
||||||
|
const actionManager = useExcalidrawActionManager();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DropdownMenuItem
|
||||||
|
data-testid="help-menu-item"
|
||||||
|
icon={HelpIcon}
|
||||||
|
onSelect={() => actionManager.executeAction(actionShortcuts)}
|
||||||
|
shortcut="?"
|
||||||
|
aria-label={t("helpDialog.title")}
|
||||||
|
>
|
||||||
|
{t("helpDialog.title")}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
Help.displayName = "Help";
|
||||||
|
|
||||||
|
export const ClearCanvas = () => {
|
||||||
|
// FIXME Hack until we tie "t" to lang state
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
const actionManager = useExcalidrawActionManager();
|
||||||
|
|
||||||
|
const [showDialog, setShowDialog] = useState(false);
|
||||||
|
const toggleDialog = () => setShowDialog(!showDialog);
|
||||||
|
|
||||||
|
if (!actionManager.isActionEnabled(actionClearCanvas)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<DropdownMenuItem
|
||||||
|
icon={TrashIcon}
|
||||||
|
onSelect={toggleDialog}
|
||||||
|
data-testid="clear-canvas-button"
|
||||||
|
aria-label={t("buttons.clearReset")}
|
||||||
|
>
|
||||||
|
{t("buttons.clearReset")}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
|
||||||
|
{/* FIXME this should live outside MainMenu so it stays open
|
||||||
|
if menu is closed */}
|
||||||
|
{showDialog && (
|
||||||
|
<ConfirmDialog
|
||||||
|
onConfirm={() => {
|
||||||
|
actionManager.executeAction(actionClearCanvas);
|
||||||
|
toggleDialog();
|
||||||
|
}}
|
||||||
|
onCancel={toggleDialog}
|
||||||
|
title={t("clearCanvasDialog.title")}
|
||||||
|
>
|
||||||
|
<p className="clear-canvas__content"> {t("alerts.clearReset")}</p>
|
||||||
|
</ConfirmDialog>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
ClearCanvas.displayName = "ClearCanvas";
|
||||||
|
|
||||||
|
export const ToggleTheme = () => {
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
const actionManager = useExcalidrawActionManager();
|
||||||
|
|
||||||
|
if (!actionManager.isActionEnabled(actionToggleTheme)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DropdownMenuItem
|
||||||
|
onSelect={() => {
|
||||||
|
return actionManager.executeAction(actionToggleTheme);
|
||||||
|
}}
|
||||||
|
icon={appState.theme === "dark" ? SunIcon : MoonIcon}
|
||||||
|
data-testid="toggle-dark-mode"
|
||||||
|
shortcut={getShortcutFromShortcutName("toggleTheme")}
|
||||||
|
aria-label={
|
||||||
|
appState.theme === "dark"
|
||||||
|
? t("buttons.lightMode")
|
||||||
|
: t("buttons.darkMode")
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{appState.theme === "dark"
|
||||||
|
? t("buttons.lightMode")
|
||||||
|
: t("buttons.darkMode")}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
ToggleTheme.displayName = "ToggleTheme";
|
||||||
|
|
||||||
|
export const ChangeCanvasBackground = () => {
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
const actionManager = useExcalidrawActionManager();
|
||||||
|
|
||||||
|
if (appState.viewModeEnabled) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div style={{ marginTop: "0.5rem" }}>
|
||||||
|
<div style={{ fontSize: ".75rem", marginBottom: ".5rem" }}>
|
||||||
|
{t("labels.canvasBackground")}
|
||||||
|
</div>
|
||||||
|
<div style={{ padding: "0 0.625rem" }}>
|
||||||
|
{actionManager.renderAction("changeViewBackgroundColor")}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
ChangeCanvasBackground.displayName = "ChangeCanvasBackground";
|
||||||
|
|
||||||
|
export const Export = () => {
|
||||||
|
// FIXME Hack until we tie "t" to lang state
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
const setAppState = useExcalidrawSetAppState();
|
||||||
|
return (
|
||||||
|
<DropdownMenuItem
|
||||||
|
icon={ExportIcon}
|
||||||
|
onSelect={() => {
|
||||||
|
setAppState({ openDialog: "jsonExport" });
|
||||||
|
}}
|
||||||
|
data-testid="json-export-button"
|
||||||
|
aria-label={t("buttons.export")}
|
||||||
|
>
|
||||||
|
{t("buttons.export")}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
Export.displayName = "Export";
|
||||||
|
|
||||||
|
export const Socials = () => (
|
||||||
|
<>
|
||||||
|
<DropdownMenuItemLink
|
||||||
|
icon={GithubIcon}
|
||||||
|
href="https://github.com/excalidraw/excalidraw"
|
||||||
|
aria-label="GitHub"
|
||||||
|
>
|
||||||
|
GitHub
|
||||||
|
</DropdownMenuItemLink>
|
||||||
|
<DropdownMenuItemLink
|
||||||
|
icon={DiscordIcon}
|
||||||
|
href="https://discord.gg/UexuTaE"
|
||||||
|
aria-label="Discord"
|
||||||
|
>
|
||||||
|
Discord
|
||||||
|
</DropdownMenuItemLink>
|
||||||
|
<DropdownMenuItemLink
|
||||||
|
icon={TwitterIcon}
|
||||||
|
href="https://twitter.com/excalidraw"
|
||||||
|
aria-label="Twitter"
|
||||||
|
>
|
||||||
|
Twitter
|
||||||
|
</DropdownMenuItemLink>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
Socials.displayName = "Socials";
|
||||||
|
|
||||||
|
export const LiveCollaborationTrigger = ({
|
||||||
|
onSelect,
|
||||||
|
isCollaborating,
|
||||||
|
}: {
|
||||||
|
onSelect: () => void;
|
||||||
|
isCollaborating: boolean;
|
||||||
|
}) => {
|
||||||
|
// FIXME Hack until we tie "t" to lang state
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
return (
|
||||||
|
<DropdownMenuItem
|
||||||
|
data-testid="collab-button"
|
||||||
|
icon={usersIcon}
|
||||||
|
className={clsx({
|
||||||
|
"active-collab": isCollaborating,
|
||||||
|
})}
|
||||||
|
onSelect={onSelect}
|
||||||
|
>
|
||||||
|
{t("labels.liveCollaboration")}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
LiveCollaborationTrigger.displayName = "LiveCollaborationTrigger";
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import React from "react";
|
||||||
|
import {
|
||||||
|
useDevice,
|
||||||
|
useExcalidrawAppState,
|
||||||
|
useExcalidrawSetAppState,
|
||||||
|
} from "../App";
|
||||||
|
import DropdownMenu from "../dropdownMenu/DropdownMenu";
|
||||||
|
|
||||||
|
import * as DefaultItems from "./DefaultItems";
|
||||||
|
|
||||||
|
import { UserList } from "../UserList";
|
||||||
|
import { t } from "../../i18n";
|
||||||
|
import { HamburgerMenuIcon } from "../icons";
|
||||||
|
|
||||||
|
const MainMenu = ({ children }: { children?: React.ReactNode }) => {
|
||||||
|
const device = useDevice();
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
const setAppState = useExcalidrawSetAppState();
|
||||||
|
const onClickOutside = device.isMobile
|
||||||
|
? undefined
|
||||||
|
: () => setAppState({ openMenu: null });
|
||||||
|
return (
|
||||||
|
<DropdownMenu open={appState.openMenu === "canvas"}>
|
||||||
|
<DropdownMenu.Trigger
|
||||||
|
onToggle={() => {
|
||||||
|
setAppState({
|
||||||
|
openMenu: appState.openMenu === "canvas" ? null : "canvas",
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{HamburgerMenuIcon}
|
||||||
|
</DropdownMenu.Trigger>
|
||||||
|
<DropdownMenu.Content onClickOutside={onClickOutside}>
|
||||||
|
{children}
|
||||||
|
{device.isMobile && appState.collaborators.size > 0 && (
|
||||||
|
<fieldset className="UserList-Wrapper">
|
||||||
|
<legend>{t("labels.collaborators")}</legend>
|
||||||
|
<UserList mobile={true} collaborators={appState.collaborators} />
|
||||||
|
</fieldset>
|
||||||
|
)}
|
||||||
|
</DropdownMenu.Content>
|
||||||
|
</DropdownMenu>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
MainMenu.Trigger = DropdownMenu.Trigger;
|
||||||
|
MainMenu.Item = DropdownMenu.Item;
|
||||||
|
MainMenu.ItemLink = DropdownMenu.ItemLink;
|
||||||
|
MainMenu.ItemCustom = DropdownMenu.ItemCustom;
|
||||||
|
MainMenu.Group = DropdownMenu.Group;
|
||||||
|
MainMenu.Separator = DropdownMenu.Separator;
|
||||||
|
MainMenu.DefaultItems = DefaultItems;
|
||||||
|
|
||||||
|
export default MainMenu;
|
||||||
|
|
||||||
|
MainMenu.displayName = "Menu";
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
import { actionLoadScene, actionShortcuts } from "../../actions";
|
||||||
|
import { getShortcutFromShortcutName } from "../../actions/shortcuts";
|
||||||
|
import { t } from "../../i18n";
|
||||||
|
import {
|
||||||
|
useDevice,
|
||||||
|
useExcalidrawActionManager,
|
||||||
|
useExcalidrawAppState,
|
||||||
|
} from "../App";
|
||||||
|
import { ExcalLogo, HelpIcon, LoadIcon, usersIcon } from "../icons";
|
||||||
|
|
||||||
|
const WelcomeScreenMenuItemContent = ({
|
||||||
|
icon,
|
||||||
|
shortcut,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
icon?: JSX.Element;
|
||||||
|
shortcut?: string | null;
|
||||||
|
children: React.ReactNode;
|
||||||
|
}) => {
|
||||||
|
const device = useDevice();
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="welcome-screen-menu-item__icon">{icon}</div>
|
||||||
|
<div className="welcome-screen-menu-item__text">{children}</div>
|
||||||
|
{shortcut && !device.isMobile && (
|
||||||
|
<div className="welcome-screen-menu-item__shortcut">{shortcut}</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
WelcomeScreenMenuItemContent.displayName = "WelcomeScreenMenuItemContent";
|
||||||
|
|
||||||
|
const WelcomeScreenMenuItem = ({
|
||||||
|
onSelect,
|
||||||
|
children,
|
||||||
|
icon,
|
||||||
|
shortcut,
|
||||||
|
className = "",
|
||||||
|
...props
|
||||||
|
}: {
|
||||||
|
onSelect: () => void;
|
||||||
|
children: React.ReactNode;
|
||||||
|
icon?: JSX.Element;
|
||||||
|
shortcut?: string | null;
|
||||||
|
} & React.ButtonHTMLAttributes<HTMLButtonElement>) => {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
{...props}
|
||||||
|
type="button"
|
||||||
|
className={`welcome-screen-menu-item ${className}`}
|
||||||
|
onClick={onSelect}
|
||||||
|
>
|
||||||
|
<WelcomeScreenMenuItemContent icon={icon} shortcut={shortcut}>
|
||||||
|
{children}
|
||||||
|
</WelcomeScreenMenuItemContent>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
WelcomeScreenMenuItem.displayName = "WelcomeScreenMenuItem";
|
||||||
|
|
||||||
|
const WelcomeScreenMenuItemLink = ({
|
||||||
|
children,
|
||||||
|
href,
|
||||||
|
icon,
|
||||||
|
shortcut,
|
||||||
|
className = "",
|
||||||
|
...props
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
href: string;
|
||||||
|
icon?: JSX.Element;
|
||||||
|
shortcut?: string | null;
|
||||||
|
} & React.AnchorHTMLAttributes<HTMLAnchorElement>) => {
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
{...props}
|
||||||
|
className={`welcome-screen-menu-item ${className}`}
|
||||||
|
href={href}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
<WelcomeScreenMenuItemContent icon={icon} shortcut={shortcut}>
|
||||||
|
{children}
|
||||||
|
</WelcomeScreenMenuItemContent>
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
WelcomeScreenMenuItemLink.displayName = "WelcomeScreenMenuItemLink";
|
||||||
|
|
||||||
|
const Center = ({ children }: { children?: React.ReactNode }) => {
|
||||||
|
return (
|
||||||
|
<div className="welcome-screen-center">
|
||||||
|
{children || (
|
||||||
|
<>
|
||||||
|
<Logo />
|
||||||
|
<Heading>{t("welcomeScreen.defaults.center_heading")}</Heading>
|
||||||
|
<Menu>
|
||||||
|
<MenuItemLoadScene />
|
||||||
|
<MenuItemHelp />
|
||||||
|
</Menu>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
Center.displayName = "Center";
|
||||||
|
|
||||||
|
const Logo = ({ children }: { children?: React.ReactNode }) => {
|
||||||
|
return (
|
||||||
|
<div className="welcome-screen-center__logo virgil welcome-screen-decor">
|
||||||
|
{children || <>{ExcalLogo} Excalidraw</>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
Logo.displayName = "Logo";
|
||||||
|
|
||||||
|
const Heading = ({ children }: { children: React.ReactNode }) => {
|
||||||
|
return (
|
||||||
|
<div className="welcome-screen-center__heading welcome-screen-decor virgil">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
Heading.displayName = "Heading";
|
||||||
|
|
||||||
|
const Menu = ({ children }: { children?: React.ReactNode }) => {
|
||||||
|
return <div className="welcome-screen-menu">{children}</div>;
|
||||||
|
};
|
||||||
|
Menu.displayName = "Menu";
|
||||||
|
|
||||||
|
const MenuItemHelp = () => {
|
||||||
|
const actionManager = useExcalidrawActionManager();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<WelcomeScreenMenuItem
|
||||||
|
onSelect={() => actionManager.executeAction(actionShortcuts)}
|
||||||
|
shortcut="?"
|
||||||
|
icon={HelpIcon}
|
||||||
|
>
|
||||||
|
{t("helpDialog.title")}
|
||||||
|
</WelcomeScreenMenuItem>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
MenuItemHelp.displayName = "MenuItemHelp";
|
||||||
|
|
||||||
|
const MenuItemLoadScene = () => {
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
const actionManager = useExcalidrawActionManager();
|
||||||
|
|
||||||
|
if (appState.viewModeEnabled) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<WelcomeScreenMenuItem
|
||||||
|
onSelect={() => actionManager.executeAction(actionLoadScene)}
|
||||||
|
shortcut={getShortcutFromShortcutName("loadScene")}
|
||||||
|
icon={LoadIcon}
|
||||||
|
>
|
||||||
|
{t("buttons.load")}
|
||||||
|
</WelcomeScreenMenuItem>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
MenuItemLoadScene.displayName = "MenuItemLoadScene";
|
||||||
|
|
||||||
|
const MenuItemLiveCollaborationTrigger = ({
|
||||||
|
onSelect,
|
||||||
|
}: {
|
||||||
|
onSelect: () => any;
|
||||||
|
}) => {
|
||||||
|
// FIXME when we tie t() to lang state
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
const appState = useExcalidrawAppState();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<WelcomeScreenMenuItem shortcut={null} onSelect={onSelect} icon={usersIcon}>
|
||||||
|
{t("labels.liveCollaboration")}
|
||||||
|
</WelcomeScreenMenuItem>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
MenuItemLiveCollaborationTrigger.displayName =
|
||||||
|
"MenuItemLiveCollaborationTrigger";
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Center.Logo = Logo;
|
||||||
|
Center.Heading = Heading;
|
||||||
|
Center.Menu = Menu;
|
||||||
|
Center.MenuItem = WelcomeScreenMenuItem;
|
||||||
|
Center.MenuItemLink = WelcomeScreenMenuItemLink;
|
||||||
|
Center.MenuItemHelp = MenuItemHelp;
|
||||||
|
Center.MenuItemLoadScene = MenuItemLoadScene;
|
||||||
|
Center.MenuItemLiveCollaborationTrigger = MenuItemLiveCollaborationTrigger;
|
||||||
|
|
||||||
|
export { Center };
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import { t } from "../../i18n";
|
||||||
|
import {
|
||||||
|
WelcomeScreenHelpArrow,
|
||||||
|
WelcomeScreenMenuArrow,
|
||||||
|
WelcomeScreenTopToolbarArrow,
|
||||||
|
} from "../icons";
|
||||||
|
|
||||||
|
const MenuHint = ({ children }: { children?: React.ReactNode }) => {
|
||||||
|
return (
|
||||||
|
<div className="virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu">
|
||||||
|
{WelcomeScreenMenuArrow}
|
||||||
|
<div className="welcome-screen-decor-hint__label">
|
||||||
|
{children || t("welcomeScreen.defaults.menuHint")}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
MenuHint.displayName = "MenuHint";
|
||||||
|
|
||||||
|
const ToolbarHint = ({ children }: { children?: React.ReactNode }) => {
|
||||||
|
return (
|
||||||
|
<div className="virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar">
|
||||||
|
<div className="welcome-screen-decor-hint__label">
|
||||||
|
{children || t("welcomeScreen.defaults.toolbarHint")}
|
||||||
|
</div>
|
||||||
|
{WelcomeScreenTopToolbarArrow}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
ToolbarHint.displayName = "ToolbarHint";
|
||||||
|
|
||||||
|
const HelpHint = ({ children }: { children?: React.ReactNode }) => {
|
||||||
|
return (
|
||||||
|
<div className="virgil welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help">
|
||||||
|
<div>{children || t("welcomeScreen.defaults.helpHint")}</div>
|
||||||
|
{WelcomeScreenHelpArrow}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
HelpHint.displayName = "HelpHint";
|
||||||
|
|
||||||
|
export { HelpHint, MenuHint, ToolbarHint };
|
||||||
+89
-78
@@ -3,29 +3,39 @@
|
|||||||
font-family: "Virgil";
|
font-family: "Virgil";
|
||||||
}
|
}
|
||||||
|
|
||||||
.WelcomeScreen-logo {
|
// WelcomeSreen common
|
||||||
display: flex;
|
// ---------------------------------------------------------------------------
|
||||||
align-items: center;
|
|
||||||
column-gap: 0.75rem;
|
|
||||||
font-size: 2.25rem;
|
|
||||||
|
|
||||||
svg {
|
.welcome-screen-decor {
|
||||||
width: 1.625rem;
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.WelcomeScreen-decor {
|
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
||||||
color: var(--color-gray-40);
|
color: var(--color-gray-40);
|
||||||
|
}
|
||||||
|
|
||||||
&--subheading {
|
&.theme--dark {
|
||||||
font-size: 1.125rem;
|
.welcome-screen-decor {
|
||||||
text-align: center;
|
color: var(--color-gray-60);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WelcomeScreen.Hints
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
.welcome-screen-decor-hint {
|
||||||
|
@media (max-height: 599px) {
|
||||||
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--help-pointer {
|
@media (max-width: 1024px), (max-width: 800px) {
|
||||||
|
.welcome-screen-decor {
|
||||||
|
&--help,
|
||||||
|
&--menu {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&--help {
|
||||||
display: flex;
|
display: flex;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
@@ -49,7 +59,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&--top-toolbar-pointer {
|
&--toolbar {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 100%;
|
top: 100%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
@@ -58,7 +68,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: baseline;
|
align-items: baseline;
|
||||||
|
|
||||||
&__label {
|
.welcome-screen-decor-hint__label {
|
||||||
width: 120px;
|
width: 120px;
|
||||||
position: relative;
|
position: relative;
|
||||||
top: -0.5rem;
|
top: -0.5rem;
|
||||||
@@ -74,7 +84,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&--menu-pointer {
|
&--menu {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 320px;
|
width: 320px;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
@@ -95,10 +105,19 @@
|
|||||||
transform: scaleX(-1);
|
transform: scaleX(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 860px) {
|
||||||
|
.welcome-screen-decor-hint__label {
|
||||||
|
max-width: 160px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.WelcomeScreen-container {
|
// WelcomeSreen.Center
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
.welcome-screen-center {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 2rem;
|
gap: 2rem;
|
||||||
@@ -112,7 +131,24 @@
|
|||||||
bottom: 1rem;
|
bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.WelcomeScreen-items {
|
.welcome-screen-center__logo {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
column-gap: 0.75rem;
|
||||||
|
font-size: 2.25rem;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: 1.625rem;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.welcome-screen-center__heading {
|
||||||
|
font-size: 1.125rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.welcome-screen-menu {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 2px;
|
gap: 2px;
|
||||||
@@ -120,7 +156,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.WelcomeScreen-item {
|
.welcome-screen-menu-item {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
pointer-events: all;
|
pointer-events: all;
|
||||||
@@ -128,8 +164,10 @@
|
|||||||
color: var(--color-gray-50);
|
color: var(--color-gray-50);
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
display: flex;
|
max-width: 400px;
|
||||||
|
display: grid;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
@@ -140,44 +178,49 @@
|
|||||||
|
|
||||||
border-radius: var(--border-radius-md);
|
border-radius: var(--border-radius-md);
|
||||||
|
|
||||||
&__label {
|
grid-template-columns: calc(var(--default-icon-size) + 0.5rem) 1fr 3rem;
|
||||||
|
|
||||||
|
&__text {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
margin-right: auto;
|
||||||
|
text-align: left;
|
||||||
column-gap: 0.5rem;
|
column-gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
svg {
|
&__icon {
|
||||||
width: var(--default-icon-size);
|
width: var(--default-icon-size);
|
||||||
height: var(--default-icon-size);
|
height: var(--default-icon-size);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__shortcut {
|
&__shortcut {
|
||||||
|
margin-left: auto;
|
||||||
color: var(--color-gray-40);
|
color: var(--color-gray-40);
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:not(:active) .WelcomeScreen-item:hover {
|
&:not(:active) .welcome-screen-menu-item:hover {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
background: var(--color-gray-10);
|
background: var(--color-gray-10);
|
||||||
|
|
||||||
.WelcomeScreen-item__shortcut {
|
.welcome-screen-menu-item__shortcut {
|
||||||
color: var(--color-gray-50);
|
color: var(--color-gray-50);
|
||||||
}
|
}
|
||||||
|
|
||||||
.WelcomeScreen-item__label {
|
.welcome-screen-menu-item__text {
|
||||||
color: var(--color-gray-100);
|
color: var(--color-gray-100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.WelcomeScreen-item:active {
|
.welcome-screen-menu-item:active {
|
||||||
background: var(--color-gray-20);
|
background: var(--color-gray-20);
|
||||||
|
|
||||||
.WelcomeScreen-item__shortcut {
|
.welcome-screen-menu-item__shortcut {
|
||||||
color: var(--color-gray-50);
|
color: var(--color-gray-50);
|
||||||
}
|
}
|
||||||
|
|
||||||
.WelcomeScreen-item__label {
|
.welcome-screen-menu-item__text {
|
||||||
color: var(--color-gray-100);
|
color: var(--color-gray-100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +228,7 @@
|
|||||||
color: var(--color-promo) !important;
|
color: var(--color-promo) !important;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
.WelcomeScreen-item__label {
|
.welcome-screen-menu-item__text {
|
||||||
color: var(--color-promo) !important;
|
color: var(--color-promo) !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,11 +236,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.theme--dark {
|
&.theme--dark {
|
||||||
.WelcomeScreen-decor {
|
.welcome-screen-menu-item {
|
||||||
color: var(--color-gray-60);
|
|
||||||
}
|
|
||||||
|
|
||||||
.WelcomeScreen-item {
|
|
||||||
color: var(--color-gray-60);
|
color: var(--color-gray-60);
|
||||||
|
|
||||||
&__shortcut {
|
&__shortcut {
|
||||||
@@ -205,69 +244,41 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:not(:active) .WelcomeScreen-item:hover {
|
&:not(:active) .welcome-screen-menu-item:hover {
|
||||||
background: var(--color-gray-85);
|
background: var(--color-gray-85);
|
||||||
|
|
||||||
.WelcomeScreen-item__shortcut {
|
.welcome-screen-menu-item__shortcut {
|
||||||
color: var(--color-gray-50);
|
color: var(--color-gray-50);
|
||||||
}
|
}
|
||||||
|
|
||||||
.WelcomeScreen-item__label {
|
.welcome-screen-menu-item__text {
|
||||||
color: var(--color-gray-10);
|
color: var(--color-gray-10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.WelcomeScreen-item:active {
|
.welcome-screen-menu-item:active {
|
||||||
background-color: var(--color-gray-90);
|
background-color: var(--color-gray-90);
|
||||||
.WelcomeScreen-item__label {
|
.welcome-screen-menu-item__text {
|
||||||
color: var(--color-gray-10);
|
color: var(--color-gray-10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can tweak these values but for an initial effort, it looks OK to me
|
|
||||||
@media (max-width: 1024px) {
|
|
||||||
.WelcomeScreen-decor {
|
|
||||||
&--help-pointer,
|
|
||||||
&--menu-pointer {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// @media (max-height: 400px) {
|
|
||||||
// .WelcomeScreen-container {
|
|
||||||
// margin-top: 0;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
@media (max-height: 599px) {
|
@media (max-height: 599px) {
|
||||||
.WelcomeScreen-container {
|
.welcome-screen-center {
|
||||||
margin-top: 4rem;
|
margin-top: 4rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@media (min-height: 600px) and (max-height: 900px) {
|
@media (min-height: 600px) and (max-height: 900px) {
|
||||||
.WelcomeScreen-container {
|
.welcome-screen-center {
|
||||||
margin-top: 8rem;
|
margin-top: 8rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@media (max-height: 630px) {
|
@media (max-height: 500px), (max-width: 320px) {
|
||||||
.WelcomeScreen-decor--top-toolbar-pointer {
|
.welcome-screen-center {
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media (max-height: 500px) {
|
|
||||||
.WelcomeScreen-container {
|
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @media (max-height: 740px) {
|
// ---------------------------------------------------------------------------
|
||||||
// .WelcomeScreen-decor {
|
|
||||||
// &--help-pointer,
|
|
||||||
// &--top-toolbar-pointer,
|
|
||||||
// &--menu-pointer {
|
|
||||||
// display: none;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { Center } from "./WelcomeScreen.Center";
|
||||||
|
import { MenuHint, ToolbarHint, HelpHint } from "./WelcomeScreen.Hints";
|
||||||
|
|
||||||
|
import "./WelcomeScreen.scss";
|
||||||
|
|
||||||
|
const WelcomeScreen = (props: { children: React.ReactNode }) => {
|
||||||
|
// NOTE this component is used as a dummy wrapper to retrieve child props
|
||||||
|
// from, and will never be rendered to DOM directly. As such, we can't
|
||||||
|
// do anything here (use hooks and such)
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
WelcomeScreen.displayName = "WelcomeScreen";
|
||||||
|
|
||||||
|
WelcomeScreen.Center = Center;
|
||||||
|
WelcomeScreen.Hints = { MenuHint, ToolbarHint, HelpHint };
|
||||||
|
|
||||||
|
export default WelcomeScreen;
|
||||||
+25
-8
@@ -130,12 +130,6 @@ export const IDLE_THRESHOLD = 60_000;
|
|||||||
// Report a user active each ACTIVE_THRESHOLD milliseconds
|
// Report a user active each ACTIVE_THRESHOLD milliseconds
|
||||||
export const ACTIVE_THRESHOLD = 3_000;
|
export const ACTIVE_THRESHOLD = 3_000;
|
||||||
|
|
||||||
export const MODES = {
|
|
||||||
VIEW: "viewMode",
|
|
||||||
ZEN: "zenMode",
|
|
||||||
GRID: "gridMode",
|
|
||||||
};
|
|
||||||
|
|
||||||
export const THEME_FILTER = cssVariables.themeFilter;
|
export const THEME_FILTER = cssVariables.themeFilter;
|
||||||
|
|
||||||
export const URL_QUERY_KEYS = {
|
export const URL_QUERY_KEYS = {
|
||||||
@@ -156,6 +150,7 @@ export const DEFAULT_UI_OPTIONS: AppProps["UIOptions"] = {
|
|||||||
toggleTheme: null,
|
toggleTheme: null,
|
||||||
saveAsImage: true,
|
saveAsImage: true,
|
||||||
},
|
},
|
||||||
|
welcomeScreen: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
// breakpoints
|
// breakpoints
|
||||||
@@ -216,8 +211,30 @@ export const TEXT_ALIGN = {
|
|||||||
|
|
||||||
export const ELEMENT_READY_TO_ERASE_OPACITY = 20;
|
export const ELEMENT_READY_TO_ERASE_OPACITY = 20;
|
||||||
|
|
||||||
export const COOKIES = {
|
// Radius represented as 25% of element's largest side (width/height).
|
||||||
AUTH_STATE_COOKIE: "excplus-auth",
|
// Used for LEGACY and PROPORTIONAL_RADIUS algorithms, or when the element is
|
||||||
|
// below the cutoff size.
|
||||||
|
export const DEFAULT_PROPORTIONAL_RADIUS = 0.25;
|
||||||
|
// Fixed radius for the ADAPTIVE_RADIUS algorithm. In pixels.
|
||||||
|
export const DEFAULT_ADAPTIVE_RADIUS = 32;
|
||||||
|
// roundness type (algorithm)
|
||||||
|
export const ROUNDNESS = {
|
||||||
|
// Used for legacy rounding (rectangles), which currently works the same
|
||||||
|
// as PROPORTIONAL_RADIUS, but we need to differentiate for UI purposes and
|
||||||
|
// forwards-compat.
|
||||||
|
LEGACY: 1,
|
||||||
|
|
||||||
|
// Used for linear elements & diamonds
|
||||||
|
PROPORTIONAL_RADIUS: 2,
|
||||||
|
|
||||||
|
// Current default algorithm for rectangles, using fixed pixel radius.
|
||||||
|
// It's working similarly to a regular border-radius, but attemps to make
|
||||||
|
// radius visually similar across differnt element sizes, especially
|
||||||
|
// very large and very small elements.
|
||||||
|
//
|
||||||
|
// NOTE right now we don't allow configuration and use a constant radius
|
||||||
|
// (see DEFAULT_ADAPTIVE_RADIUS constant)
|
||||||
|
ADAPTIVE_RADIUS: 3,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
/** key containt id of precedeing elemnt id we use in reconciliation during
|
/** key containt id of precedeing elemnt id we use in reconciliation during
|
||||||
|
|||||||
+18
-4
@@ -408,7 +408,7 @@
|
|||||||
pointer-events: all;
|
pointer-events: all;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: var(--button-hover);
|
background-color: var(--button-hover-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
@@ -540,9 +540,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mobile-misc-tools-container {
|
.mobile-misc-tools-container {
|
||||||
position: fixed;
|
position: absolute;
|
||||||
top: 5rem;
|
top: calc(5rem - var(--editor-container-padding));
|
||||||
right: 0;
|
right: calc(var(--editor-container-padding) * -1);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
border: 1px solid var(--sidebar-border-color);
|
border: 1px solid var(--sidebar-border-color);
|
||||||
@@ -569,6 +569,20 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.UserList-Wrapper {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: none;
|
||||||
|
text-align: left;
|
||||||
|
|
||||||
|
legend {
|
||||||
|
display: block;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 400;
|
||||||
|
margin: 0 0 0.25rem;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.ErrorSplash.excalidraw {
|
.ErrorSplash.excalidraw {
|
||||||
|
|||||||
+3
-2
@@ -35,13 +35,14 @@
|
|||||||
--shadow-island: 0px 7px 14px rgba(0, 0, 0, 0.05),
|
--shadow-island: 0px 7px 14px rgba(0, 0, 0, 0.05),
|
||||||
0px 0px 3.12708px rgba(0, 0, 0, 0.0798),
|
0px 0px 3.12708px rgba(0, 0, 0, 0.0798),
|
||||||
0px 0px 0.931014px rgba(0, 0, 0, 0.1702);
|
0px 0px 0.931014px rgba(0, 0, 0, 0.1702);
|
||||||
--button-hover: var(--color-gray-10);
|
--button-hover-bg: var(--color-gray-10);
|
||||||
--default-border-color: var(--color-gray-30);
|
--default-border-color: var(--color-gray-30);
|
||||||
|
|
||||||
--default-button-size: 2rem;
|
--default-button-size: 2rem;
|
||||||
--default-icon-size: 1rem;
|
--default-icon-size: 1rem;
|
||||||
--lg-button-size: 2.25rem;
|
--lg-button-size: 2.25rem;
|
||||||
--lg-icon-size: 1rem;
|
--lg-icon-size: 1rem;
|
||||||
|
--editor-container-padding: 1rem;
|
||||||
|
|
||||||
@media screen and (min-device-width: 1921px) {
|
@media screen and (min-device-width: 1921px) {
|
||||||
--lg-button-size: 2.5rem;
|
--lg-button-size: 2.5rem;
|
||||||
@@ -135,7 +136,7 @@
|
|||||||
--popup-text-inverted-color: #2c2c2c;
|
--popup-text-inverted-color: #2c2c2c;
|
||||||
--select-highlight-color: #{$oc-blue-4};
|
--select-highlight-color: #{$oc-blue-4};
|
||||||
--text-primary-color: var(--color-gray-40);
|
--text-primary-color: var(--color-gray-40);
|
||||||
--button-hover: var(--color-gray-80);
|
--button-hover-bg: var(--color-gray-80);
|
||||||
--default-border-color: var(--color-gray-80);
|
--default-border-color: var(--color-gray-80);
|
||||||
--shadow-island: 0px 13px 33px rgba(0, 0, 0, 0.07),
|
--shadow-island: 0px 13px 33px rgba(0, 0, 0, 0.07),
|
||||||
0px 4.13px 9.94853px rgba(0, 0, 0, 0.0456112),
|
0px 4.13px 9.94853px rgba(0, 0, 0, 0.0456112),
|
||||||
|
|||||||
@@ -39,11 +39,11 @@
|
|||||||
|
|
||||||
.ToolIcon__icon {
|
.ToolIcon__icon {
|
||||||
&:hover {
|
&:hover {
|
||||||
background: var(--button-hover);
|
background: var(--button-hover-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
background: var(--button-hover);
|
background: var(--button-hover-bg);
|
||||||
border: 1px solid var(--color-primary-darkest);
|
border: 1px solid var(--color-primary-darkest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,24 +54,25 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0.625rem;
|
padding: 0.625rem;
|
||||||
width: var(--default-button-size);
|
width: var(--button-width, var(--default-button-size));
|
||||||
height: var(--default-button-size);
|
height: var(--button-height, var(--default-button-size));
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-color: var(--default-border-color);
|
border-color: var(--button-border, var(--default-border-color));
|
||||||
border-radius: var(--border-radius-lg);
|
border-radius: var(--border-radius-lg);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background-color: transparent;
|
background-color: var(--button-bg, var(--island-bg-color));
|
||||||
color: var(--text-primary-color);
|
color: var(--button-color, var(--text-primary-color));
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: var(--button-hover);
|
background-color: var(--button-hover-bg);
|
||||||
|
border-color: var(--button-hover-border, var(--default-border-color));
|
||||||
}
|
}
|
||||||
|
|
||||||
&:active {
|
&:active {
|
||||||
background-color: var(--button-hover);
|
background-color: var(--button-active-bg);
|
||||||
border-color: var(--color-primary-darkest);
|
border-color: var(--button-active-border, var(--color-primary-darkest));
|
||||||
}
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
@@ -83,7 +84,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
color: var(--color-primary-darker);
|
color: var(--button-color, var(--color-primary-darker));
|
||||||
|
|
||||||
|
width: var(--button-width, var(--lg-icon-size));
|
||||||
|
height: var(--button-height, var(--lg-icon-size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -154,7 +154,8 @@ class Library {
|
|||||||
return this.setLibrary(() => {
|
return this.setLibrary(() => {
|
||||||
return new Promise<LibraryItems>(async (resolve, reject) => {
|
return new Promise<LibraryItems>(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const source = await (typeof libraryItems === "function"
|
const source = await (typeof libraryItems === "function" &&
|
||||||
|
!(libraryItems instanceof Blob)
|
||||||
? libraryItems(this.lastLibraryItems)
|
? libraryItems(this.lastLibraryItems)
|
||||||
: libraryItems);
|
: libraryItems);
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user