From 12e37e3dd21113588f15b2690aafb715a13ffc87 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Mon, 31 Jul 2023 15:29:24 +0200 Subject: [PATCH 1/8] fix: forgotten REACT_APP env variables (#6834) --- .env.production | 4 ++-- package.json | 4 ++-- src/excalidraw-app/sentry.ts | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.env.production b/.env.production index e3ece6df3c..b0570f2a03 100644 --- a/.env.production +++ b/.env.production @@ -1,5 +1,5 @@ -REACT_APP_BACKEND_V2_GET_URL=https://json.excalidraw.com/api/v2/ -REACT_APP_BACKEND_V2_POST_URL=https://json.excalidraw.com/api/v2/post/ +VITE_APP_BACKEND_V2_GET_URL=https://json.excalidraw.com/api/v2/ +VITE_APP_BACKEND_V2_POST_URL=https://json.excalidraw.com/api/v2/post/ VITE_APP_LIBRARY_URL=https://libraries.excalidraw.com VITE_APP_LIBRARY_BACKEND=https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries diff --git a/package.json b/package.json index 3880ffce51..66b1a777ee 100644 --- a/package.json +++ b/package.json @@ -101,8 +101,8 @@ "private": true, "scripts": { "build-node": "node ./scripts/build-node.js", - "build:app:docker": "cross-env REACT_APP_DISABLE_SENTRY=true REACT_APP_DISABLE_TRACKING=true vite build", - "build:app": "cross-env REACT_APP_GIT_SHA=$VERCEL_GIT_COMMIT_SHA vite build", + "build:app:docker": "cross-env VITE_APP_DISABLE_SENTRY=true VITE_APP_DISABLE_TRACKING=true vite build", + "build:app": "cross-env VITE_APP_GIT_SHA=$VERCEL_GIT_COMMIT_SHA vite build", "build:version": "node ./scripts/build-version.js", "build": "yarn build:app && yarn build:version", "fix:code": "yarn test:code --fix", diff --git a/src/excalidraw-app/sentry.ts b/src/excalidraw-app/sentry.ts index 6ad0d49f8d..d224a266af 100644 --- a/src/excalidraw-app/sentry.ts +++ b/src/excalidraw-app/sentry.ts @@ -6,12 +6,11 @@ const SentryEnvHostnameMap: { [key: string]: string } = { "vercel.app": "staging", }; -const REACT_APP_DISABLE_SENTRY = - import.meta.env.VITE_APP_DISABLE_SENTRY === "true"; +const SENTRY_DISABLED = import.meta.env.VITE_APP_DISABLE_SENTRY === "true"; // Disable Sentry locally or inside the Docker to avoid noise/respect privacy const onlineEnv = - !REACT_APP_DISABLE_SENTRY && + !SENTRY_DISABLED && Object.keys(SentryEnvHostnameMap).find( (item) => window.location.hostname.indexOf(item) >= 0, ); From 6126c34dc089bae6a1654fc31cdaa7ce0dd4deb6 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Mon, 31 Jul 2023 19:56:50 +0530 Subject: [PATCH 2/8] fix: add self destroying service-worker.js to migrate everyone from CRA to Vite (#6833) * fix: add self destroying service-worker.js to migrate everyone from CRA to VITE * add comment * don't add service-worker.js to app pre-cache --- public/service-worker.js | 20 ++++++++++++++++++++ vite.config.ts | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 public/service-worker.js diff --git a/public/service-worker.js b/public/service-worker.js new file mode 100644 index 0000000000..55afd7e21d --- /dev/null +++ b/public/service-worker.js @@ -0,0 +1,20 @@ +// Since we migrated to Vite, the service worker strategy changed, in CRA it was a custom service worker named service-worker.js and in Vite its sw.js handled by vite-plugin-pwa +// Due to this the existing CRA users were not able to migrate to Vite or any new changes post Vite unless browser is hard refreshed +// Hence adding a self destroying worker so all CRA service workers are destroyed and migrated to Vite +// We should remove this code after sometime when we are confident that +// all users have migrated to Vite + +self.addEventListener("install", () => { + self.skipWaiting(); +}); + +self.addEventListener("activate", () => { + self.registration + .unregister() + .then(() => { + return self.clients.matchAll(); + }) + .then((clients) => { + clients.forEach((client) => client.navigate(client.url)); + }); +}); diff --git a/vite.config.ts b/vite.config.ts index 4a4d72e3d9..c7a75cd250 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -61,7 +61,7 @@ export default defineConfig({ workbox: { // Don't push fonts and locales to app precache - globIgnores: ["fonts.css", "**/locales/**"], + globIgnores: ["fonts.css", "**/locales/**", "service-worker.js"], runtimeCaching: [ { urlPattern: new RegExp("/.+.(ttf|woff2|otf)"), From fc9a9a2571c6a5a323e967b6cde090d59391a9a2 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Mon, 31 Jul 2023 16:36:30 +0200 Subject: [PATCH 3/8] fix: eye-dropper not working with app offset correctly on non-1 dPR (#6835) --- src/components/EyeDropper.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/EyeDropper.tsx b/src/components/EyeDropper.tsx index 9e452ce88a..8e3e21ece3 100644 --- a/src/components/EyeDropper.tsx +++ b/src/components/EyeDropper.tsx @@ -77,8 +77,8 @@ export const EyeDropper: React.FC<{ colorPreviewDiv.style.left = `${clientX + 20}px`; const pixel = ctx.getImageData( - clientX * window.devicePixelRatio - appState.offsetLeft, - clientY * window.devicePixelRatio - appState.offsetTop, + (clientX - appState.offsetLeft) * window.devicePixelRatio, + (clientY - appState.offsetTop) * window.devicePixelRatio, 1, 1, ).data; From 50450a7dabc794a04e553bf461ab03d19bd1298e Mon Sep 17 00:00:00 2001 From: Ives van Hoorne Date: Mon, 31 Jul 2023 23:47:41 +0200 Subject: [PATCH 4/8] chore: update required node version to 18 (#6837) --- .codesandbox/Dockerfile | 5 +++++ .codesandbox/tasks.json | 11 +++++++++-- .nvmrc | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .codesandbox/Dockerfile diff --git a/.codesandbox/Dockerfile b/.codesandbox/Dockerfile new file mode 100644 index 0000000000..fd5b38d1e8 --- /dev/null +++ b/.codesandbox/Dockerfile @@ -0,0 +1,5 @@ +FROM node:18-bullseye + +# Vite wants to open the browser using `open`, so we +# need to install those utils. +RUN apt update -y && apt install -y xdg-utils diff --git a/.codesandbox/tasks.json b/.codesandbox/tasks.json index 360636c4c0..51c6e4e16f 100644 --- a/.codesandbox/tasks.json +++ b/.codesandbox/tasks.json @@ -27,7 +27,10 @@ "start": { "name": "Start Excalidraw", "command": "yarn start", - "runAtStart": true + "runAtStart": true, + "preview": { + "port": 3000 + } }, "test": { "name": "Run Tests", @@ -37,7 +40,11 @@ "install-deps": { "name": "Install Dependencies", "command": "yarn install", - "restartOn": { "files": ["yarn.lock"] } + "restartOn": { + "files": ["yarn.lock"], + "branch": false, + "resume": false + } } } } diff --git a/.nvmrc b/.nvmrc index 8351c19397..3c032078a4 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -14 +18 From 9391a09e54047b12adb8a57aaff8354f47201357 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 11:07:16 +0530 Subject: [PATCH 5/8] build(deps): bump word-wrap from 1.2.3 to 1.2.5 (#6811) Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.5. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.5) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index b43a518933..91a1317a45 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7439,9 +7439,9 @@ why-is-node-running@^2.2.2: stackback "0.0.2" word-wrap@^1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" - integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== + version "1.2.5" + resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34" + integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== workbox-background-sync@7.0.0: version "7.0.0" From b85d5fa12b4d50e34458439eb084f205ae49ce88 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Tue, 1 Aug 2023 16:13:04 +0530 Subject: [PATCH 6/8] test: add coverage report for PR (#6840) * test: add coverage report for PR * gh token * fix * fix * add reporter * fix * enable v8 for coverage * no watch * test * add threshold * fix * change name so the action isn't required * change job name * rename job so it doesn't collid with test required check * remove log --- .github/workflows/test-coverage-pr.yml | 26 ++++++ package.json | 6 +- vitest.config.ts | 7 ++ yarn.lock | 111 +++++++++++++++++++++++-- 4 files changed, 140 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/test-coverage-pr.yml diff --git a/.github/workflows/test-coverage-pr.yml b/.github/workflows/test-coverage-pr.yml new file mode 100644 index 0000000000..76c818298a --- /dev/null +++ b/.github/workflows/test-coverage-pr.yml @@ -0,0 +1,26 @@ +name: Test Coverage PR +on: + pull_request: + +jobs: + coverage: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + + steps: + - uses: actions/checkout@v2 + - name: "Install Node" + uses: actions/setup-node@v2 + with: + node-version: "18.x" + - name: "Install Deps" + run: yarn --frozen-lockfile + - name: "Test Coverage" + run: yarn test:coverage + - name: "Report Coverage" + if: always() # Also generate the report if tests are failing + uses: davelosert/vitest-coverage-report-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index 66b1a777ee..8929905695 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "@types/resize-observer-browser": "0.1.7", "@types/socket.io-client": "1.4.36", "@vitejs/plugin-react": "3.1.0", + "@vitest/coverage-v8": "0.33.0", "@vitest/ui": "0.32.2", "chai": "4.3.6", "dotenv": "16.0.1", @@ -114,14 +115,15 @@ "prettier": "prettier \"**/*.{css,scss,json,md,html,yml}\" --ignore-path=.eslintignore", "start": "vite", "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 --watch=false", "test:app": "vitest --config vitest.config.ts", "test:code": "eslint --max-warnings=0 --ext .js,.ts,.tsx .", "test:other": "yarn prettier --list-different", "test:typecheck": "tsc", "test:update": "yarn test:app --update --watch=false", "test": "yarn test:app", - "test:coverage": "vitest --coverage --watchAll", + "test:coverage": "vitest --coverage", + "test:coverage:watch": "vitest --coverage --watch", "test:ui": "yarn test --ui", "autorelease": "node scripts/autorelease.js", "prerelease": "node scripts/prerelease.js", diff --git a/vitest.config.ts b/vitest.config.ts index e7d08704da..51a4df95fb 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -5,5 +5,12 @@ export default defineConfig({ setupFiles: ["./src/setupTests.ts"], globals: true, environment: "jsdom", + coverage: { + reporter: ["text", "json-summary", "json"], + lines: 70, + branches: 70, + functions: 68, + statements: 70, + }, }, }); diff --git a/yarn.lock b/yarn.lock index 91a1317a45..0dce0be7c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,7 +2,7 @@ # yarn lockfile v1 -"@ampproject/remapping@^2.2.0": +"@ampproject/remapping@^2.2.0", "@ampproject/remapping@^2.2.1": version "2.2.1" resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.1.tgz#99e8e11851128b8702cd57c33684f1d0f260b630" integrity sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg== @@ -1260,6 +1260,11 @@ "@babel/helper-validator-identifier" "^7.22.5" to-fast-properties "^2.0.0" +"@bcoe/v8-coverage@^0.2.3": + version "0.2.3" + resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" + integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== + "@braintree/sanitize-url@6.0.2": version "6.0.2" resolved "https://registry.yarnpkg.com/@braintree/sanitize-url/-/sanitize-url-6.0.2.tgz#6110f918d273fe2af8ea1c4398a88774bb9fc12f" @@ -1812,6 +1817,11 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== +"@istanbuljs/schema@^0.1.2": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98" + integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA== + "@jest/expect-utils@^29.5.0": version "29.5.0" resolved "https://registry.yarnpkg.com/@jest/expect-utils/-/expect-utils-29.5.0.tgz#f74fad6b6e20f924582dc8ecbf2cb800fe43a036" @@ -1870,12 +1880,12 @@ resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== -"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.13": +"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.13", "@jridgewell/sourcemap-codec@^1.4.15": version "1.4.15" resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== -"@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.9": +"@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.9": version "0.3.18" resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz#25783b2086daf6ff1dcb53c9249ae480e4dd4cd6" integrity sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA== @@ -2500,7 +2510,7 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.1.tgz#aa22750962f3bf0e79d753d3cc067f010c95f194" integrity sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA== -"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0": +"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1": version "2.0.4" resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#8467d4b3c087805d63580480890791277ce35c44" integrity sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g== @@ -2786,6 +2796,23 @@ magic-string "^0.27.0" react-refresh "^0.14.0" +"@vitest/coverage-v8@0.33.0": + version "0.33.0" + resolved "https://registry.yarnpkg.com/@vitest/coverage-v8/-/coverage-v8-0.33.0.tgz#dfcb36cf51624a89d33ab0962a6eec8a41346ef2" + integrity sha512-Rj5IzoLF7FLj6yR7TmqsfRDSeaFki6NAJ/cQexqhbWkHEV2htlVGrmuOde3xzvFsCbLCagf4omhcIaVmfU8Okg== + dependencies: + "@ampproject/remapping" "^2.2.1" + "@bcoe/v8-coverage" "^0.2.3" + istanbul-lib-coverage "^3.2.0" + istanbul-lib-report "^3.0.0" + istanbul-lib-source-maps "^4.0.1" + istanbul-reports "^3.1.5" + magic-string "^0.30.1" + picocolors "^1.0.0" + std-env "^3.3.3" + test-exclude "^6.0.0" + v8-to-istanbul "^9.1.0" + "@vitest/expect@0.32.2": version "0.32.2" resolved "https://registry.yarnpkg.com/@vitest/expect/-/expect-0.32.2.tgz#8111f6ab1ff3b203efbe3a25e8bb2d160ce4b720" @@ -3502,7 +3529,7 @@ confusing-browser-globals@^1.0.11: resolved "https://registry.yarnpkg.com/confusing-browser-globals/-/confusing-browser-globals-1.0.11.tgz#ae40e9b57cdd3915408a2805ebd3a5585608dc81" integrity sha512-JsPKdmh8ZkmnHxDk55FZ1TqVLvEQTvoByJZRN9jzI0UjxK/QgAmsphz7PGtqgPieQZ/CQcHWXCR7ATDNhGe+YA== -convert-source-map@^1.7.0: +convert-source-map@^1.6.0, convert-source-map@^1.7.0: version "1.9.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.9.0.tgz#7faae62353fb4213366d0ca98358d22e8368b05f" integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A== @@ -4559,7 +4586,7 @@ glob-parent@^5.1.2, glob-parent@~5.1.2: dependencies: is-glob "^4.0.1" -glob@^7.1.3, glob@^7.1.6: +glob@^7.1.3, glob@^7.1.4, glob@^7.1.6: version "7.2.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== @@ -4694,6 +4721,11 @@ html-encoding-sniffer@^3.0.0: dependencies: whatwg-encoding "^2.0.0" +html-escaper@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" + integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== + http-parser-js@>=0.5.1: version "0.5.8" resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.8.tgz#af23090d9ac4e24573de6f6aecc9d84a48bf20e3" @@ -5083,6 +5115,37 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== +istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz#189e7909d0a39fa5a3dfad5b03f71947770191d3" + integrity sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw== + +istanbul-lib-report@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz#908305bac9a5bd175ac6a74489eafd0fc2445a7d" + integrity sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw== + dependencies: + istanbul-lib-coverage "^3.0.0" + make-dir "^4.0.0" + supports-color "^7.1.0" + +istanbul-lib-source-maps@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz#895f3a709fcfba34c6de5a42939022f3e4358551" + integrity sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw== + dependencies: + debug "^4.1.1" + istanbul-lib-coverage "^3.0.0" + source-map "^0.6.1" + +istanbul-reports@^3.1.5: + version "3.1.6" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.6.tgz#2544bcab4768154281a2f0870471902704ccaa1a" + integrity sha512-TLgnMkKg3iTDsQ9PbPTdpfAK2DzjF9mqUG7RMgcQl8oFjad8ob4laGxv5XV5U9MAfx8D6tSJiUyuAwzLicaxlg== + dependencies: + html-escaper "^2.0.0" + istanbul-lib-report "^3.0.0" + jake@^10.8.5: version "10.8.5" resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.5.tgz#f2183d2c59382cb274226034543b9c03b8164c46" @@ -5505,6 +5568,20 @@ magic-string@^0.30.0: dependencies: "@jridgewell/sourcemap-codec" "^1.4.13" +magic-string@^0.30.1: + version "0.30.2" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.2.tgz#dcf04aad3d0d1314bc743d076c50feb29b3c7aca" + integrity sha512-lNZdu7pewtq/ZvWUp9Wpf/x7WzMTsR26TWV03BRZrXFsv+BI6dy8RAiKgm1uM/kyR0rCfUcqvOlXKG66KhIGug== + dependencies: + "@jridgewell/sourcemap-codec" "^1.4.15" + +make-dir@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-4.0.0.tgz#c3c2307a771277cd9638305f915c29ae741b614e" + integrity sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw== + dependencies: + semver "^7.5.3" + md5-hex@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/md5-hex/-/md5-hex-3.0.1.tgz#be3741b510591434b2784d79e556eefc2c9a8e5c" @@ -6455,7 +6532,7 @@ semver@^7.2.1, semver@^7.3.2, semver@^7.3.7: dependencies: lru-cache "^6.0.0" -semver@^7.3.4, semver@^7.5.0: +semver@^7.3.4, semver@^7.5.0, semver@^7.5.3: version "7.5.4" resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== @@ -6626,7 +6703,7 @@ stackback@0.0.2: resolved "https://registry.yarnpkg.com/stackback/-/stackback-0.0.2.tgz#1ac8a0d9483848d1695e418b6d031a3c3ce68e3b" integrity sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw== -std-env@^3.3.2: +std-env@^3.3.2, std-env@^3.3.3: version "3.3.3" resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.3.3.tgz#a54f06eb245fdcfef53d56f3c0251f1d5c3d01fe" integrity sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg== @@ -6834,6 +6911,15 @@ terser@^5.0.0: commander "^2.20.0" source-map-support "~0.5.20" +test-exclude@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e" + integrity sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w== + dependencies: + "@istanbuljs/schema" "^0.1.2" + glob "^7.1.4" + minimatch "^3.0.4" + text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -7136,6 +7222,15 @@ v8-compile-cache@^2.0.3: resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== +v8-to-istanbul@^9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz#1b83ed4e397f58c85c266a570fc2558b5feb9265" + integrity sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA== + dependencies: + "@jridgewell/trace-mapping" "^0.3.12" + "@types/istanbul-lib-coverage" "^2.0.1" + convert-source-map "^1.6.0" + vite-node@0.32.2: version "0.32.2" resolved "https://registry.yarnpkg.com/vite-node/-/vite-node-0.32.2.tgz#bfccdfeb708b2309ea9e5fe424951c75bb9c0096" From 23c88a38d0504e333465960a928832b99b0ecb70 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 16:14:08 +0530 Subject: [PATCH 7/8] build(deps): bump semver from 5.7.1 to 5.7.2 in /dev-docs (#6757) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- dev-docs/yarn.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/dev-docs/yarn.lock b/dev-docs/yarn.lock index 6206a60e9b..194a38e750 100644 --- a/dev-docs/yarn.lock +++ b/dev-docs/yarn.lock @@ -6611,19 +6611,19 @@ semver@7.0.0: integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== semver@^5.4.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + version "5.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" + integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + version "6.3.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" + integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7: - version "7.3.7" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f" - integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== dependencies: lru-cache "^6.0.0" From bb985eba3ae6cd2944522111c0cfd928b62b92bf Mon Sep 17 00:00:00 2001 From: Alex Kim <45559664+alex-kim-dev@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:04:21 +0500 Subject: [PATCH 8/8] fix: resizing arrow labels (#6789) * fix arrow labels resizing - min arrow labels width based on font size - labels width and padding in % of container's width - resize labels simply multiplying by scale * remove no longer needed getContainerDims * fix arrow labels font size not updated on change font size action * fix bound arrows not updated right after resize * fix test * fix 3+ point arrow label resizing with shift * fix bound text not scaling when resizing with shift & n or s handle * fix arrow labels width not updating when moving a 2-point arrow point with shift --------- Co-authored-by: Aakansha Doshi --- src/components/App.tsx | 6 +- src/constants.ts | 3 + src/element/linearElementEditor.ts | 8 +-- src/element/resizeElements.ts | 99 +++++++++++++------------- src/element/textElement.ts | 45 ++++++------ src/element/textWysiwyg.tsx | 8 +-- src/tests/linearElementEditor.test.tsx | 8 +-- 7 files changed, 89 insertions(+), 88 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 4c202441d6..28d8401bd0 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -298,7 +298,6 @@ import { getApproxMinLineWidth, getBoundTextElement, getContainerCenter, - getContainerDims, getContainerElement, getDefaultLineHeight, getLineHeightInPx, @@ -3548,9 +3547,8 @@ class App extends React.Component { lineHeight, ); const minHeight = getApproxMinLineHeight(fontSize, lineHeight); - const containerDims = getContainerDims(container); - const newHeight = Math.max(containerDims.height, minHeight); - const newWidth = Math.max(containerDims.width, minWidth); + const newHeight = Math.max(container.height, minHeight); + const newWidth = Math.max(container.width, minWidth); mutateElement(container, { height: newHeight, width: newWidth }); sceneX = container.x + newWidth / 2; sceneY = container.y + newHeight / 2; diff --git a/src/constants.ts b/src/constants.ts index 4c6b67e2c0..6ef98af17f 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -117,6 +117,7 @@ export const FRAME_STYLE = { export const WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji"; +export const MIN_FONT_SIZE = 1; export const DEFAULT_FONT_SIZE = 20; export const DEFAULT_FONT_FAMILY: FontFamilyValues = FONT_FAMILY.Virgil; export const DEFAULT_TEXT_ALIGN = "left"; @@ -239,6 +240,8 @@ export const VERSIONS = { } as const; export const BOUND_TEXT_PADDING = 5; +export const ARROW_LABEL_WIDTH_FRACTION = 0.7; +export const ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO = 11; export const VERTICAL_ALIGN = { TOP: "top", diff --git a/src/element/linearElementEditor.ts b/src/element/linearElementEditor.ts index b10493e0dc..3426b3e1a8 100644 --- a/src/element/linearElementEditor.ts +++ b/src/element/linearElementEditor.ts @@ -264,11 +264,11 @@ export class LinearElementEditor { }; }), ); + } - const boundTextElement = getBoundTextElement(element); - if (boundTextElement) { - handleBindTextResize(element, false); - } + const boundTextElement = getBoundTextElement(element); + if (boundTextElement) { + handleBindTextResize(element, false); } // suggest bindings for first and last point if selected diff --git a/src/element/resizeElements.ts b/src/element/resizeElements.ts index b9fd63287b..136c70fb8c 100644 --- a/src/element/resizeElements.ts +++ b/src/element/resizeElements.ts @@ -1,4 +1,4 @@ -import { SHIFT_LOCKING_ANGLE } from "../constants"; +import { MIN_FONT_SIZE, SHIFT_LOCKING_ANGLE } from "../constants"; import { rescalePoints } from "../points"; import { @@ -204,8 +204,6 @@ const rescalePointsInElement = ( } : {}; -const MIN_FONT_SIZE = 1; - const measureFontSizeFromWidth = ( element: NonDeleted, nextWidth: number, @@ -589,24 +587,42 @@ export const resizeSingleElement = ( }); } + if ( + isArrowElement(element) && + boundTextElement && + shouldMaintainAspectRatio + ) { + const fontSize = + (resizedElement.width / element.width) * boundTextElement.fontSize; + if (fontSize < MIN_FONT_SIZE) { + return; + } + boundTextFont.fontSize = fontSize; + } + if ( resizedElement.width !== 0 && resizedElement.height !== 0 && Number.isFinite(resizedElement.x) && Number.isFinite(resizedElement.y) ) { + mutateElement(element, resizedElement); + updateBoundElements(element, { newSize: { width: resizedElement.width, height: resizedElement.height }, }); - mutateElement(element, resizedElement); if (boundTextElement && boundTextFont != null) { mutateElement(boundTextElement, { fontSize: boundTextFont.fontSize, baseline: boundTextFont.baseline, }); } - handleBindTextResize(element, transformHandleDirection); + handleBindTextResize( + element, + transformHandleDirection, + shouldMaintainAspectRatio, + ); } }; @@ -722,12 +738,8 @@ export const resizeMultipleElements = ( fontSize?: ExcalidrawTextElement["fontSize"]; baseline?: ExcalidrawTextElement["baseline"]; scale?: ExcalidrawImageElement["scale"]; + boundTextFontSize?: ExcalidrawTextElement["fontSize"]; }; - boundText: { - element: ExcalidrawTextElementWithContainer; - fontSize: ExcalidrawTextElement["fontSize"]; - baseline: ExcalidrawTextElement["baseline"]; - } | null; }[] = []; for (const { orig, latest } of targetElements) { @@ -798,50 +810,39 @@ export const resizeMultipleElements = ( } } - let boundText: typeof elementsAndUpdates[0]["boundText"] = null; - - const boundTextElement = getBoundTextElement(latest); - - if (boundTextElement || isTextElement(orig)) { - const updatedElement = { - ...latest, - width, - height, - }; - const metrics = measureFontSizeFromWidth( - boundTextElement ?? (orig as ExcalidrawTextElement), - boundTextElement - ? getBoundTextMaxWidth(updatedElement) - : updatedElement.width, - boundTextElement - ? getBoundTextMaxHeight(updatedElement, boundTextElement) - : updatedElement.height, - ); - + if (isTextElement(orig)) { + const metrics = measureFontSizeFromWidth(orig, width, height); if (!metrics) { return; } - - if (isTextElement(orig)) { - update.fontSize = metrics.size; - update.baseline = metrics.baseline; - } - - if (boundTextElement) { - boundText = { - element: boundTextElement, - fontSize: metrics.size, - baseline: metrics.baseline, - }; - } + update.fontSize = metrics.size; + update.baseline = metrics.baseline; } - elementsAndUpdates.push({ element: latest, update, boundText }); + const boundTextElement = pointerDownState.originalElements.get( + getBoundTextElementId(orig) ?? "", + ) as ExcalidrawTextElementWithContainer | undefined; + + if (boundTextElement) { + const newFontSize = boundTextElement.fontSize * scale; + if (newFontSize < MIN_FONT_SIZE) { + return; + } + update.boundTextFontSize = newFontSize; + } + + elementsAndUpdates.push({ + element: latest, + update, + }); } const elementsToUpdate = elementsAndUpdates.map(({ element }) => element); - for (const { element, update, boundText } of elementsAndUpdates) { + for (const { + element, + update: { boundTextFontSize, ...update }, + } of elementsAndUpdates) { const { width, height, angle } = update; mutateElement(element, update, false); @@ -851,17 +852,17 @@ export const resizeMultipleElements = ( newSize: { width, height }, }); - if (boundText) { - const { element: boundTextElement, ...boundTextUpdates } = boundText; + const boundTextElement = getBoundTextElement(element); + if (boundTextElement && boundTextFontSize) { mutateElement( boundTextElement, { - ...boundTextUpdates, + fontSize: boundTextFontSize, angle: isLinearElement(element) ? undefined : angle, }, false, ); - handleBindTextResize(element, transformHandleType); + handleBindTextResize(element, transformHandleType, true); } } diff --git a/src/element/textElement.ts b/src/element/textElement.ts index 76de2c886a..61813d2b4a 100644 --- a/src/element/textElement.ts +++ b/src/element/textElement.ts @@ -10,6 +10,8 @@ import { } from "./types"; import { mutateElement } from "./mutateElement"; import { + ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO, + ARROW_LABEL_WIDTH_FRACTION, BOUND_TEXT_PADDING, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, @@ -65,7 +67,7 @@ export const redrawTextBoundingBox = ( boundTextUpdates.text = textElement.text; if (container) { - maxWidth = getBoundTextMaxWidth(container); + maxWidth = getBoundTextMaxWidth(container, textElement); boundTextUpdates.text = wrapText( textElement.originalText, getFontString(textElement), @@ -83,13 +85,12 @@ export const redrawTextBoundingBox = ( boundTextUpdates.baseline = metrics.baseline; if (container) { - const containerDims = getContainerDims(container); const maxContainerHeight = getBoundTextMaxHeight( container, textElement as ExcalidrawTextElementWithContainer, ); - let nextHeight = containerDims.height; + let nextHeight = container.height; if (metrics.height > maxContainerHeight) { nextHeight = computeContainerDimensionForBoundText( metrics.height, @@ -155,6 +156,7 @@ export const bindTextToShapeAfterDuplication = ( export const handleBindTextResize = ( container: NonDeletedExcalidrawElement, transformHandleType: MaybeTransformHandleType, + shouldMaintainAspectRatio = false, ) => { const boundTextElementId = getBoundTextElementId(container); if (!boundTextElementId) { @@ -175,15 +177,17 @@ export const handleBindTextResize = ( let text = textElement.text; let nextHeight = textElement.height; let nextWidth = textElement.width; - const containerDims = getContainerDims(container); const maxWidth = getBoundTextMaxWidth(container); const maxHeight = getBoundTextMaxHeight( container, textElement as ExcalidrawTextElementWithContainer, ); - let containerHeight = containerDims.height; + let containerHeight = container.height; let nextBaseLine = textElement.baseline; - if (transformHandleType !== "n" && transformHandleType !== "s") { + if ( + shouldMaintainAspectRatio || + (transformHandleType !== "n" && transformHandleType !== "s") + ) { if (text) { text = wrapText( textElement.originalText, @@ -207,7 +211,7 @@ export const handleBindTextResize = ( container.type, ); - const diff = containerHeight - containerDims.height; + const diff = containerHeight - container.height; // fix the y coord when resizing from ne/nw/n const updatedY = !isArrowElement(container) && @@ -687,16 +691,6 @@ export const getContainerElement = ( return null; }; -export const getContainerDims = (element: ExcalidrawElement) => { - const MIN_WIDTH = 300; - if (isArrowElement(element)) { - const width = Math.max(element.width, MIN_WIDTH); - const height = element.height; - return { width, height }; - } - return { width: element.width, height: element.height }; -}; - export const getContainerCenter = ( container: ExcalidrawElement, appState: AppState, @@ -887,12 +881,19 @@ export const computeContainerDimensionForBoundText = ( return dimension + padding; }; -export const getBoundTextMaxWidth = (container: ExcalidrawElement) => { - const width = getContainerDims(container).width; +export const getBoundTextMaxWidth = ( + container: ExcalidrawElement, + boundTextElement: ExcalidrawTextElement | null = getBoundTextElement( + container, + ), +) => { + const { width } = container; if (isArrowElement(container)) { - return width - BOUND_TEXT_PADDING * 8 * 2; + const minWidth = + (boundTextElement?.fontSize ?? DEFAULT_FONT_SIZE) * + ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO; + return Math.max(ARROW_LABEL_WIDTH_FRACTION * width, minWidth); } - if (container.type === "ellipse") { // The width of the largest rectangle inscribed inside an ellipse is // Math.round((ellipse.width / 2) * Math.sqrt(2)) which is derived from @@ -911,7 +912,7 @@ export const getBoundTextMaxHeight = ( container: ExcalidrawElement, boundTextElement: ExcalidrawTextElementWithContainer, ) => { - const height = getContainerDims(container).height; + const { height } = container; if (isArrowElement(container)) { const containerHeight = height - BOUND_TEXT_PADDING * 8 * 2; if (containerHeight <= 0) { diff --git a/src/element/textWysiwyg.tsx b/src/element/textWysiwyg.tsx index 9105ba700a..a5bf701434 100644 --- a/src/element/textWysiwyg.tsx +++ b/src/element/textWysiwyg.tsx @@ -23,7 +23,6 @@ import { AppState } from "../types"; import { mutateElement } from "./mutateElement"; import { getBoundTextElementId, - getContainerDims, getContainerElement, getTextElementAngle, getTextWidth, @@ -177,20 +176,19 @@ export const textWysiwyg = ({ updatedTextElement, editable, ); - const containerDims = getContainerDims(container); let originalContainerData; if (propertiesUpdated) { originalContainerData = updateOriginalContainerCache( container.id, - containerDims.height, + container.height, ); } else { originalContainerData = originalContainerCache[container.id]; if (!originalContainerData) { originalContainerData = updateOriginalContainerCache( container.id, - containerDims.height, + container.height, ); } } @@ -214,7 +212,7 @@ export const textWysiwyg = ({ // autoshrink container height until original container height // is reached when text is removed !isArrowElement(container) && - containerDims.height > originalContainerData.height && + container.height > originalContainerData.height && textElementHeight < maxHeight ) { const targetContainerHeight = computeContainerDimensionForBoundText( diff --git a/src/tests/linearElementEditor.test.tsx b/src/tests/linearElementEditor.test.tsx index 6bcefb95ff..bcca0b1e1c 100644 --- a/src/tests/linearElementEditor.test.tsx +++ b/src/tests/linearElementEditor.test.tsx @@ -1128,7 +1128,7 @@ describe("Test Linear Elements", () => { height: 500, }); const arrow = UI.createElement("arrow", { - x: 210, + x: -10, y: 250, width: 400, height: 1, @@ -1152,8 +1152,8 @@ describe("Test Linear Elements", () => { expect( wrapText(textElement.originalText, font, getBoundTextMaxWidth(arrow)), ).toMatchInlineSnapshot(` - "Online whiteboard collaboration - made easy" + "Online whiteboard + collaboration made easy" `); const handleBindTextResizeSpy = vi.spyOn( textElementUtils, @@ -1165,7 +1165,7 @@ describe("Test Linear Elements", () => { mouse.moveTo(200, 0); mouse.upAt(200, 0); - expect(arrow.width).toBe(170); + expect(arrow.width).toBe(200); expect(rect.x).toBe(200); expect(rect.y).toBe(0); expect(handleBindTextResizeSpy).toHaveBeenCalledWith(