From 720f468f39ff2c51f40d8084e79313dac5e6fea8 Mon Sep 17 00:00:00 2001 From: Ryan Di Date: Wed, 24 Aug 2022 14:44:59 +0800 Subject: [PATCH 01/11] fix: improve solveQuadratic when a = 0 (#5618) --- src/element/bounds.ts | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/src/element/bounds.ts b/src/element/bounds.ts index 90d75eeba..b6f655ec4 100644 --- a/src/element/bounds.ts +++ b/src/element/bounds.ts @@ -107,12 +107,19 @@ const solveQuadratic = ( return false; } - const t1 = (-b + Math.sqrt(sqrtPart)) / (2 * a); - const t2 = (-b - Math.sqrt(sqrtPart)) / (2 * a); - let s1 = null; let s2 = null; + let t1 = Infinity; + let t2 = Infinity; + + if (a === 0) { + t1 = t2 = -c / b; + } else { + t1 = (-b + Math.sqrt(sqrtPart)) / (2 * a); + t2 = (-b - Math.sqrt(sqrtPart)) / (2 * a); + } + if (t1 >= 0 && t1 <= 1) { s1 = getBezierValueForT(t1, p0, p1, p2, p3); } @@ -152,11 +159,6 @@ const getCubicBezierCurveBound = ( return [minX, minY, maxX, maxY]; }; -// TODO: https://github.com/excalidraw/excalidraw/issues/5617 -const getRandomOffset = () => { - return Math.random() / 1000000; -}; - const getMinMaxXYFromCurvePathOps = ( ops: Op[], transformXY?: (x: number, y: number) => [number, number], @@ -173,19 +175,9 @@ const getMinMaxXYFromCurvePathOps = ( // move operation does not draw anything; so, it always // returns false } else if (op === "bcurveTo") { - // random offset is needed to fix https://github.com/excalidraw/excalidraw/issues/5585 - const _p1 = [ - data[0] + getRandomOffset(), - data[1] + getRandomOffset(), - ] as Point; - const _p2 = [ - data[2] + getRandomOffset(), - data[3] + getRandomOffset(), - ] as Point; - const _p3 = [ - data[4] + getRandomOffset(), - data[5] + getRandomOffset(), - ] as Point; + const _p1 = [data[0], data[1]] as Point; + const _p2 = [data[2], data[3]] as Point; + const _p3 = [data[4], data[5]] as Point; const p1 = transformXY ? transformXY(..._p1) : _p1; const p2 = transformXY ? transformXY(..._p2) : _p2; From 43b13d8e3ab458bf564f65ae9c98fd62dea2362b Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Fri, 26 Aug 2022 11:46:19 +0530 Subject: [PATCH 02/11] fix: Add display name to components so it doesn't show as anonymous (#5616) --- src/actions/actionExport.tsx | 2 +- src/actions/manager.tsx | 1 + src/components/ColorPicker.tsx | 2 ++ src/components/ToolButton.tsx | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/actions/actionExport.tsx b/src/actions/actionExport.tsx index 015e52162..a566e5bf9 100644 --- a/src/actions/actionExport.tsx +++ b/src/actions/actionExport.tsx @@ -244,7 +244,7 @@ export const actionLoadScene = register({ } }, keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.key === KEYS.O, - PanelComponent: ({ updateData, appState }) => ( + PanelComponent: ({ updateData }) => ( { diff --git a/src/components/ColorPicker.tsx b/src/components/ColorPicker.tsx index 76a66b5bf..22f9eb267 100644 --- a/src/components/ColorPicker.tsx +++ b/src/components/ColorPicker.tsx @@ -343,6 +343,8 @@ const ColorInput = React.forwardRef( }, ); +ColorInput.displayName = "ColorInput"; + export const ColorPicker = ({ type, color, diff --git a/src/components/ToolButton.tsx b/src/components/ToolButton.tsx index 328c135c6..7077898f3 100644 --- a/src/components/ToolButton.tsx +++ b/src/components/ToolButton.tsx @@ -187,3 +187,5 @@ ToolButton.defaultProps = { className: "", size: "medium", }; + +ToolButton.displayName = "ToolButton"; From 2b4462c9411c4b089ef409749f92062f2646c060 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Fri, 26 Aug 2022 11:46:34 +0530 Subject: [PATCH 03/11] refactor: reuse common ui dialogs and message for mobile and LayerUI (#5611) * refactor: Move common UI dialogs to component * refactor * fix --- src/components/LayerUI.tsx | 137 ++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 71 deletions(-) diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx index 2d871508a..2db1786bd 100644 --- a/src/components/LayerUI.tsx +++ b/src/components/LayerUI.tsx @@ -381,7 +381,7 @@ const LayerUI = ({ ); }; - const dialogs = ( + return ( <> {appState.isLoading && } {appState.errorMessage && ( @@ -409,82 +409,77 @@ const LayerUI = ({ } /> )} - - ); - - return device.isMobile ? ( - <> - {dialogs} - onLockToggle()} - onPenModeToggle={onPenModeToggle} - canvas={canvas} - isCollaborating={isCollaborating} - renderCustomFooter={renderCustomFooter} - showThemeBtn={showThemeBtn} - onImageAction={onImageAction} - renderTopRightUI={renderTopRightUI} - renderCustomStats={renderCustomStats} - /> - - ) : ( - <> -
- {dialogs} - {renderFixedSideContainer()} -
onLockToggle()} + onPenModeToggle={onPenModeToggle} + canvas={canvas} + isCollaborating={isCollaborating} renderCustomFooter={renderCustomFooter} - showExitZenModeBtn={showExitZenModeBtn} + showThemeBtn={showThemeBtn} + onImageAction={onImageAction} + renderTopRightUI={renderTopRightUI} + renderCustomStats={renderCustomStats} /> - {appState.showStats && ( - + {renderFixedSideContainer()} +
{ - actionManager.executeAction(actionToggleStats); - }} - renderCustomStats={renderCustomStats} + actionManager={actionManager} + renderCustomFooter={renderCustomFooter} + showExitZenModeBtn={showExitZenModeBtn} /> - )} - {appState.scrolledOutside && ( - - )} -
+ {appState.showStats && ( + { + actionManager.executeAction(actionToggleStats); + }} + renderCustomStats={renderCustomStats} + /> + )} + {appState.scrolledOutside && ( + + )} + + )} {appState.isLibraryOpen && (
{libraryMenu}
)} From f9b7cfd8aa5235aa08a19c15d1c9d0d954a5d94d Mon Sep 17 00:00:00 2001 From: David Luzar Date: Sat, 27 Aug 2022 23:02:17 +0200 Subject: [PATCH 04/11] fix: reintroduce help dialog button (#5631) --- src/components/Footer.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 297a2124d..420aeb6a8 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -88,6 +88,13 @@ const Footer = ({ > {renderCustomFooter?.(false, appState)} +
+ {actionManager.renderAction("toggleShortcuts")} +
Date: Mon, 29 Aug 2022 15:44:10 +0530 Subject: [PATCH 05/11] fix: don't render library menu twice for mobile (#5636) --- src/components/LayerUI.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx index 2db1786bd..ba08bf7c0 100644 --- a/src/components/LayerUI.tsx +++ b/src/components/LayerUI.tsx @@ -478,11 +478,11 @@ const LayerUI = ({ {t("buttons.scrollBackToContent")} )} + {appState.isLibraryOpen && ( +
{libraryMenu}
+ )} )} - {appState.isLibraryOpen && ( -
{libraryMenu}
- )} ); }; From 59a1d192d268f403c3d946c52f28960a0045c357 Mon Sep 17 00:00:00 2001 From: Ives van Hoorne Date: Mon, 29 Aug 2022 15:22:04 +0200 Subject: [PATCH 06/11] chore: update CodeSandbox links and add a config (#5624) * chore: update CodeSandbox links and add a config * Update tasks.json --- .codesandbox/tasks.json | 43 +++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .codesandbox/tasks.json diff --git a/.codesandbox/tasks.json b/.codesandbox/tasks.json new file mode 100644 index 000000000..360636c4c --- /dev/null +++ b/.codesandbox/tasks.json @@ -0,0 +1,43 @@ +{ + // These tasks will run in order when initializing your CodeSandbox project. + "setupTasks": [ + { + "name": "Install Dependencies", + "command": "yarn install" + } + ], + + // These tasks can be run from CodeSandbox. Running one will open a log in the app. + "tasks": { + "build": { + "name": "Build", + "command": "yarn build", + "runAtStart": false + }, + "fix": { + "name": "Fix", + "command": "yarn fix", + "runAtStart": false + }, + "prettier": { + "name": "Prettify", + "command": "yarn prettier", + "runAtStart": false + }, + "start": { + "name": "Start Excalidraw", + "command": "yarn start", + "runAtStart": true + }, + "test": { + "name": "Run Tests", + "command": "yarn test", + "runAtStart": false + }, + "install-deps": { + "name": "Install Dependencies", + "command": "yarn install", + "restartOn": { "files": ["yarn.lock"] } + } + } +} diff --git a/README.md b/README.md index 51f706382..45fec41ba 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ Try out [`@excalidraw/excalidraw`](https://www.npmjs.com/package/@excalidraw/exc ### Code Sandbox -- Go to https://codesandbox.io/s/github/excalidraw/excalidraw +- Go to https://codesandbox.io/p/github/excalidraw/excalidraw - You may need to sign in with GitHub and reload the page - You can start coding instantly, and even send PRs from there! From 553b493f37c198a5556d3f7f00914c21eabec8bb Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Mon, 29 Aug 2022 19:26:03 +0530 Subject: [PATCH 07/11] fix: library actions inside the sidebar (#5638) --- src/components/LayerUI.tsx | 92 +++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx index ba08bf7c0..d52c68d44 100644 --- a/src/components/LayerUI.tsx +++ b/src/components/LayerUI.tsx @@ -432,56 +432,58 @@ const LayerUI = ({ )} {!device.isMobile && ( -
- {renderFixedSideContainer()} -
- {appState.showStats && ( - +
+ {renderFixedSideContainer()} +
{ - actionManager.executeAction(actionToggleStats); - }} - renderCustomStats={renderCustomStats} + actionManager={actionManager} + renderCustomFooter={renderCustomFooter} + showExitZenModeBtn={showExitZenModeBtn} /> - )} - {appState.scrolledOutside && ( - - )} + {appState.showStats && ( + { + actionManager.executeAction(actionToggleStats); + }} + renderCustomStats={renderCustomStats} + /> + )} + {appState.scrolledOutside && ( + + )} +
{appState.isLibraryOpen && (
{libraryMenu}
)} -
+ )} ); From da4fa91ffc2bf9b1b74c9fec8164348273a9cad2 Mon Sep 17 00:00:00 2001 From: DanielJGeiger <1852529+DanielJGeiger@users.noreply.github.com> Date: Tue, 30 Aug 2022 02:07:18 -0500 Subject: [PATCH 08/11] chore: Dedupe webpack configs. (#5449) * chore: Dedupe package dependencies and webpack configs. * Fully dedupe `src/packages` via symlinks * Merge https://github.com/excalidraw/excalidraw into dedupe-package-deps-configs * fix: Link `tsc` so `build:example` works in @excalidraw/excalidraw * @excalidraw/plugins: Revert the `yarn.lock` deduping. * Drop yarn commands from the root `package.json`. * Remove more unneeded `package.json` additions. * One more change to drop in `package.json` files. * Deduping: Move even more into common webpack configs. * renaming Co-authored-by: Aakansha Doshi --- src/packages/common.webpack.dev.config.js | 88 +++++++++++++ src/packages/common.webpack.prod.config.js | 119 ++++++++++++++++++ src/packages/excalidraw/webpack.dev.config.js | 89 +------------ .../excalidraw/webpack.prod.config.js | 112 +---------------- src/packages/utils/webpack.prod.config.js | 49 +------- 5 files changed, 223 insertions(+), 234 deletions(-) create mode 100644 src/packages/common.webpack.dev.config.js create mode 100644 src/packages/common.webpack.prod.config.js diff --git a/src/packages/common.webpack.dev.config.js b/src/packages/common.webpack.dev.config.js new file mode 100644 index 000000000..0ee82688c --- /dev/null +++ b/src/packages/common.webpack.dev.config.js @@ -0,0 +1,88 @@ +const path = require("path"); +const autoprefixer = require("autoprefixer"); +const webpack = require("webpack"); +const { parseEnvVariables } = require(path.resolve(global.__childdir, "./env")); + +module.exports = { + mode: "development", + devtool: false, + output: { + libraryTarget: "umd", + filename: "[name].js", + publicPath: "", + }, + resolve: { + extensions: [".js", ".ts", ".tsx", ".css", ".scss"], + }, + module: { + rules: [ + { + test: /\.(sa|sc|c)ss$/, + exclude: /node_modules/, + use: [ + "style-loader", + { loader: "css-loader" }, + { + loader: "postcss-loader", + options: { + postcssOptions: { + plugins: [autoprefixer()], + }, + }, + }, + "sass-loader", + ], + }, + { + test: /\.(ts|tsx|js|jsx|mjs)$/, + exclude: /node_modules\/(?!browser-fs-access)/, + use: [ + { + loader: "ts-loader", + options: { + transpileOnly: true, + configFile: path.resolve(__dirname, "./tsconfig.dev.json"), + }, + }, + ], + }, + { + test: /\.(woff|woff2|eot|ttf|otf)$/, + type: "asset/resource", + }, + ], + }, + optimization: { + splitChunks: { + chunks: "async", + cacheGroups: { + vendors: { + test: /[\\/]node_modules[\\/]/, + name: "vendor", + }, + }, + }, + }, + plugins: [ + new webpack.EvalSourceMapDevToolPlugin({ exclude: /vendor/ }), + new webpack.DefinePlugin({ + "process.env": parseEnvVariables( + path.resolve(__dirname, "../../.env.development"), + ), + }), + ], + externals: { + react: { + root: "React", + commonjs2: "react", + commonjs: "react", + amd: "react", + }, + "react-dom": { + root: "ReactDOM", + commonjs2: "react-dom", + commonjs: "react-dom", + amd: "react-dom", + }, + }, +}; diff --git a/src/packages/common.webpack.prod.config.js b/src/packages/common.webpack.prod.config.js new file mode 100644 index 000000000..f0cca725d --- /dev/null +++ b/src/packages/common.webpack.prod.config.js @@ -0,0 +1,119 @@ +const path = require("path"); +const autoprefixer = require("autoprefixer"); +const webpack = require("webpack"); +const BundleAnalyzerPlugin = require(path.resolve( + path.join(global.__childdir, "node_modules"), + "webpack-bundle-analyzer", +)).BundleAnalyzerPlugin; +const TerserPlugin = require("terser-webpack-plugin"); +const { parseEnvVariables } = + "__noenv" in global ? {} : require(path.resolve(global.__childdir, "./env")); + +module.exports = { + mode: "production", + output: { + libraryTarget: "umd", + filename: "[name].js", + publicPath: "", + }, + resolve: { + extensions: [".js", ".ts", ".tsx", ".css", ".scss"], + }, + module: { + rules: [ + { + test: /\.(sa|sc|c)ss$/, + exclude: /node_modules/, + use: [ + "style-loader", + { + loader: "css-loader", + }, + { + loader: "postcss-loader", + options: { + postcssOptions: { + plugins: [autoprefixer()], + }, + }, + }, + "sass-loader", + ], + }, + { + test: /\.(ts|tsx|js|jsx|mjs)$/, + exclude: /node_modules\/(?!browser-fs-access)/, + use: [ + { + loader: "ts-loader", + options: { + transpileOnly: true, + configFile: path.resolve(__dirname, "./tsconfig.prod.json"), + }, + }, + { + loader: "babel-loader", + options: { + presets: [ + "@babel/preset-env", + ["@babel/preset-react", { runtime: "automatic" }], + "@babel/preset-typescript", + ], + plugins: [ + "transform-class-properties", + "@babel/plugin-transform-runtime", + ], + }, + }, + ], + }, + { + test: /\.(woff|woff2|eot|ttf|otf)$/, + type: "asset/resource", + }, + ], + }, + optimization: { + minimize: true, + minimizer: [ + new TerserPlugin({ + test: /\.js($|\?)/i, + }), + ], + splitChunks: { + chunks: "async", + cacheGroups: { + vendors: { + test: /[\\/]node_modules[\\/]/, + name: "vendor", + }, + }, + }, + }, + plugins: [ + ...(process.env.ANALYZER === "true" ? [new BundleAnalyzerPlugin()] : []), + ...("__noenv" in global + ? [] + : [ + new webpack.DefinePlugin({ + "process.env": parseEnvVariables( + path.resolve(__dirname, "../../.env.production"), + ), + }), + ]), + ], + externals: { + react: { + root: "React", + commonjs2: "react", + commonjs: "react", + amd: "react", + }, + "react-dom": { + root: "ReactDOM", + commonjs2: "react-dom", + commonjs: "react-dom", + amd: "react-dom", + }, + }, +}; diff --git a/src/packages/excalidraw/webpack.dev.config.js b/src/packages/excalidraw/webpack.dev.config.js index 9e8180f5f..5b535186f 100644 --- a/src/packages/excalidraw/webpack.dev.config.js +++ b/src/packages/excalidraw/webpack.dev.config.js @@ -1,97 +1,18 @@ +global.__childdir = __dirname; const path = require("path"); -const webpack = require("webpack"); -const autoprefixer = require("autoprefixer"); -const { parseEnvVariables } = require("./env"); +const { merge } = require("webpack-merge"); +const commonConfig = require("../common.webpack.dev.config"); const outputDir = process.env.EXAMPLE === "true" ? "example/public" : "dist"; -module.exports = { - mode: "development", - devtool: false, +const config = { entry: { "excalidraw.development": "./entry.js", }, output: { path: path.resolve(__dirname, outputDir), library: "ExcalidrawLib", - libraryTarget: "umd", - filename: "[name].js", chunkFilename: "excalidraw-assets-dev/[name]-[contenthash].js", assetModuleFilename: "excalidraw-assets-dev/[name][ext]", - - publicPath: "", - }, - resolve: { - extensions: [".js", ".ts", ".tsx", ".css", ".scss"], - }, - module: { - rules: [ - { - test: /\.(sa|sc|c)ss$/, - exclude: /node_modules/, - use: [ - "style-loader", - { loader: "css-loader" }, - { - loader: "postcss-loader", - options: { - postcssOptions: { - plugins: [autoprefixer()], - }, - }, - }, - "sass-loader", - ], - }, - { - test: /\.(ts|tsx|js|jsx|mjs)$/, - exclude: /node_modules\/(?!browser-fs-access)/, - use: [ - { - loader: "ts-loader", - options: { - transpileOnly: true, - configFile: path.resolve(__dirname, "../tsconfig.dev.json"), - }, - }, - ], - }, - { - test: /\.(woff|woff2|eot|ttf|otf)$/, - type: "asset/resource", - }, - ], - }, - optimization: { - splitChunks: { - chunks: "async", - cacheGroups: { - vendors: { - test: /[\\/]node_modules[\\/]/, - name: "vendor", - }, - }, - }, - }, - plugins: [ - new webpack.EvalSourceMapDevToolPlugin({ exclude: /vendor/ }), - new webpack.DefinePlugin({ - "process.env": parseEnvVariables( - path.resolve(__dirname, "../../../.env.development"), - ), - }), - ], - externals: { - react: { - root: "React", - commonjs2: "react", - commonjs: "react", - amd: "react", - }, - "react-dom": { - root: "ReactDOM", - commonjs2: "react-dom", - commonjs: "react-dom", - amd: "react-dom", - }, }, }; +module.exports = merge(commonConfig, config); diff --git a/src/packages/excalidraw/webpack.prod.config.js b/src/packages/excalidraw/webpack.prod.config.js index 0450d36fa..593287076 100644 --- a/src/packages/excalidraw/webpack.prod.config.js +++ b/src/packages/excalidraw/webpack.prod.config.js @@ -1,119 +1,17 @@ +global.__childdir = __dirname; const path = require("path"); -const TerserPlugin = require("terser-webpack-plugin"); -const BundleAnalyzerPlugin = - require("webpack-bundle-analyzer").BundleAnalyzerPlugin; -const autoprefixer = require("autoprefixer"); -const webpack = require("webpack"); -const { parseEnvVariables } = require("./env"); +const { merge } = require("webpack-merge"); +const commonConfig = require("../common.webpack.prod.config"); -module.exports = { - mode: "production", +const config = { entry: { "excalidraw.production.min": "./entry.js", }, output: { path: path.resolve(__dirname, "dist"), library: "ExcalidrawLib", - libraryTarget: "umd", - filename: "[name].js", chunkFilename: "excalidraw-assets/[name]-[contenthash].js", assetModuleFilename: "excalidraw-assets/[name][ext]", - publicPath: "", - }, - resolve: { - extensions: [".js", ".ts", ".tsx", ".css", ".scss"], - }, - module: { - rules: [ - { - test: /\.(sa|sc|c)ss$/, - exclude: /node_modules/, - use: [ - "style-loader", - { - loader: "css-loader", - }, - { - loader: "postcss-loader", - options: { - postcssOptions: { - plugins: [autoprefixer()], - }, - }, - }, - "sass-loader", - ], - }, - { - test: /\.(ts|tsx|js|jsx|mjs)$/, - exclude: /node_modules\/(?!browser-fs-access)/, - use: [ - { - loader: "ts-loader", - options: { - transpileOnly: true, - configFile: path.resolve(__dirname, "../tsconfig.prod.json"), - }, - }, - { - loader: "babel-loader", - options: { - presets: [ - "@babel/preset-env", - ["@babel/preset-react", { runtime: "automatic" }], - "@babel/preset-typescript", - ], - plugins: [ - "transform-class-properties", - "@babel/plugin-transform-runtime", - ], - }, - }, - ], - }, - { - test: /\.(woff|woff2|eot|ttf|otf)$/, - type: "asset/resource", - }, - ], - }, - optimization: { - minimize: true, - minimizer: [ - new TerserPlugin({ - test: /\.js($|\?)/i, - }), - ], - splitChunks: { - chunks: "async", - cacheGroups: { - vendors: { - test: /[\\/]node_modules[\\/]/, - name: "vendor", - }, - }, - }, - }, - plugins: [ - ...(process.env.ANALYZER === "true" ? [new BundleAnalyzerPlugin()] : []), - new webpack.DefinePlugin({ - "process.env": parseEnvVariables( - path.resolve(__dirname, "../../../.env.production"), - ), - }), - ], - externals: { - react: { - root: "React", - commonjs2: "react", - commonjs: "react", - amd: "react", - }, - "react-dom": { - root: "ReactDOM", - commonjs2: "react-dom", - commonjs: "react-dom", - amd: "react-dom", - }, }, }; +module.exports = merge(commonConfig, config); diff --git a/src/packages/utils/webpack.prod.config.js b/src/packages/utils/webpack.prod.config.js index 7238ad029..58a6bbf08 100644 --- a/src/packages/utils/webpack.prod.config.js +++ b/src/packages/utils/webpack.prod.config.js @@ -1,60 +1,23 @@ +global.__childdir = __dirname; +global.__noenv = true; const webpack = require("webpack"); const path = require("path"); -const BundleAnalyzerPlugin = - require("webpack-bundle-analyzer").BundleAnalyzerPlugin; +const { merge } = require("webpack-merge"); +const commonConfig = require("../common.webpack.prod.config"); -module.exports = { - mode: "production", +const config = { entry: { "excalidraw-utils.min": "./index.js" }, output: { path: path.resolve(__dirname, "dist"), - filename: "[name].js", library: "ExcalidrawUtils", - libraryTarget: "umd", - }, - resolve: { - extensions: [".tsx", ".ts", ".js", ".css", ".scss"], }, optimization: { runtimeChunk: false, }, - module: { - rules: [ - { - test: /\.(sa|sc|c)ss$/, - exclude: /node_modules/, - use: ["style-loader", { loader: "css-loader" }, "sass-loader"], - }, - { - test: /\.(ts|tsx|js)$/, - use: [ - { - loader: "ts-loader", - options: { - transpileOnly: true, - configFile: path.resolve(__dirname, "../tsconfig.prod.json"), - }, - }, - { - loader: "babel-loader", - - options: { - presets: [ - "@babel/preset-env", - ["@babel/preset-react", { runtime: "automatic" }], - "@babel/preset-typescript", - ], - plugins: [["@babel/plugin-transform-runtime"]], - }, - }, - ], - }, - ], - }, plugins: [ new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1, }), - ...(process.env.ANALYZER === "true" ? [new BundleAnalyzerPlugin()] : []), ], }; +module.exports = merge(commonConfig, config); From 836120c14b648567cad2bbc6fccc5c0775a639c7 Mon Sep 17 00:00:00 2001 From: zsviczian Date: Tue, 30 Aug 2022 09:18:24 +0200 Subject: [PATCH 09/11] feat: added exportPadding to PNG (blob) export in @excalidraw/utils (#5626) * added exportPadding * Update README.md * Update CHANGELOG.md --- src/packages/excalidraw/CHANGELOG.md | 1 + src/packages/excalidraw/README.md | 8 ++++++-- src/packages/utils.ts | 8 ++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/packages/excalidraw/CHANGELOG.md b/src/packages/excalidraw/CHANGELOG.md index 9bd7d6d5f..4fab8e8d4 100644 --- a/src/packages/excalidraw/CHANGELOG.md +++ b/src/packages/excalidraw/CHANGELOG.md @@ -18,6 +18,7 @@ Please add the latest change on the top under the correct section. #### Features - Added support for storing [`customData`](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#storing-custom-data-to-excalidraw-elements) on Excalidraw elements [#5592]. +- Added `exportPadding?: number;` to [exportToCanvas](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#exporttocanvas) and [exportToBlob](https://github.com/excalidraw/excalidraw/blob/master/src/packages/excalidraw/README.md#exporttoblob). The default value of the padding is 10. #### Breaking Changes diff --git a/src/packages/excalidraw/README.md b/src/packages/excalidraw/README.md index 5c9a73595..1d09fb5b0 100644 --- a/src/packages/excalidraw/README.md +++ b/src/packages/excalidraw/README.md @@ -929,7 +929,8 @@ This function normalizes library items elements, adding missing values when need elements, appState getDimensions, - files + files, + exportPadding?: number; }: ExportOpts @@ -940,6 +941,7 @@ This function normalizes library items elements, adding missing values when need | getDimensions | `(width: number, height: number) => { width: number, height: number, scale?: number }` | undefined | A function which returns the `width`, `height`, and optionally `scale` (defaults `1`), with which canvas is to be exported. | | maxWidthOrHeight | `number` | undefined | The maximum width or height of the exported image. If provided, `getDimensions` is ignored. | | files | [BinaryFiles](The [`BinaryFiles`](<[BinaryFiles](https://github.com/excalidraw/excalidraw/blob/master/src/types.ts#L64)>) | undefined | The files added to the scene. | +| exportPadding | number | 10 | The padding to be added on canvas | **How to use** @@ -957,7 +959,8 @@ This function returns the canvas with the exported elements, appState and dimens exportToBlob( opts: ExportOpts & { mimeType?: string, - quality?: number; + quality?: number, + exportPadding?: number; }) @@ -966,6 +969,7 @@ exportToBlob( | opts | | | This param is passed to `exportToCanvas`. You can refer to [`exportToCanvas`](#exportToCanvas) | | mimeType | string | "image/png" | Indicates the image format | | quality | number | 0.92 | A value between 0 and 1 indicating the [image quality](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#parameters). Applies only to `image/jpeg`/`image/webp` MIME types. | +| exportPadding | number | 10 | The padding to be added on canvas | **How to use** diff --git a/src/packages/utils.ts b/src/packages/utils.ts index 4d9a8af17..d81995080 100644 --- a/src/packages/utils.ts +++ b/src/packages/utils.ts @@ -35,7 +35,10 @@ export const exportToCanvas = ({ files, maxWidthOrHeight, getDimensions, -}: ExportOpts) => { + exportPadding, +}: ExportOpts & { + exportPadding?: number; +}) => { const { elements: restoredElements, appState: restoredAppState } = restore( { elements, appState }, null, @@ -46,7 +49,7 @@ export const exportToCanvas = ({ getNonDeletedElements(restoredElements), { ...restoredAppState, offsetTop: 0, offsetLeft: 0, width: 0, height: 0 }, files || {}, - { exportBackground, viewBackgroundColor }, + { exportBackground, exportPadding, viewBackgroundColor }, (width: number, height: number) => { const canvas = document.createElement("canvas"); @@ -87,6 +90,7 @@ export const exportToBlob = async ( opts: ExportOpts & { mimeType?: string; quality?: number; + exportPadding?: number; }, ): Promise => { let { mimeType = MIME_TYPES.png, quality } = opts; From a271e42af1931ad0be26d2c9ff8b322562fb7a4b Mon Sep 17 00:00:00 2001 From: Excalidraw Bot <77840495+excalibot@users.noreply.github.com> Date: Thu, 1 Sep 2022 10:06:54 +0200 Subject: [PATCH 10/11] chore: Update translations from Crowdin (#5596) * New translations en.json (Vietnamese) * Auto commit: Calculate translation coverage * New translations en.json (Lithuanian) * Auto commit: Calculate translation coverage * New translations en.json (Lithuanian) * Auto commit: Calculate translation coverage * New translations en.json (Bengali) * Auto commit: Calculate translation coverage * New translations en.json (Bengali) * Auto commit: Calculate translation coverage --- src/locales/bn-BD.json | 100 +++++++++++++++++------------------ src/locales/lt-LT.json | 10 ++-- src/locales/percentages.json | 6 +-- src/locales/vi-VN.json | 22 ++++---- 4 files changed, 69 insertions(+), 69 deletions(-) diff --git a/src/locales/bn-BD.json b/src/locales/bn-BD.json index 11993ef9b..c34b2d357 100644 --- a/src/locales/bn-BD.json +++ b/src/locales/bn-BD.json @@ -1,55 +1,55 @@ { "labels": { - "paste": "", - "pasteCharts": "", - "selectAll": "", - "multiSelect": "", - "moveCanvas": "", - "cut": "", - "copy": "", - "copyAsPng": "", - "copyAsSvg": "", - "copyText": "", - "bringForward": "", - "sendToBack": "", - "bringToFront": "", - "sendBackward": "", - "delete": "", - "copyStyles": "", - "pasteStyles": "", - "stroke": "", - "background": "", - "fill": "", - "strokeWidth": "", - "strokeStyle": "", - "strokeStyle_solid": "", - "strokeStyle_dashed": "", - "strokeStyle_dotted": "", - "sloppiness": "", - "opacity": "", - "textAlign": "", - "edges": "", - "sharp": "", - "round": "", - "arrowheads": "", - "arrowhead_none": "", - "arrowhead_arrow": "", - "arrowhead_bar": "", - "arrowhead_dot": "", - "arrowhead_triangle": "", - "fontSize": "", - "fontFamily": "", - "onlySelected": "", - "withBackground": "", - "exportEmbedScene": "", - "exportEmbedScene_details": "", + "paste": "পেস্ট করুন", + "pasteCharts": "চার্টগুলো পেস্ট করুন", + "selectAll": "সব সিলেক্ট করুন", + "multiSelect": "সিলেকশনে এলিমেন্ট এ্যাড করুন", + "moveCanvas": "ক্যানভাস মুভ করুন", + "cut": "কাট করুন", + "copy": "কপি করুন", + "copyAsPng": "PNG হিসেবে ক্লিপবোর্ডে কপি করুন", + "copyAsSvg": "SVG হিসেবে ক্লিপবোর্ডে কপি করুন", + "copyText": "টেক্সট হিসেবে ক্লিপবোর্ডে কপি করুন", + "bringForward": "সামনে আনুন", + "sendToBack": "একদম পেছনে পাঠান", + "bringToFront": "একদম সামনে আনুন", + "sendBackward": "পেছনে পাঠান", + "delete": "ডিলিট করুন", + "copyStyles": "স্টাইলগুলো কপি করুন", + "pasteStyles": "স্টাইলগুলো পেস্ট করুন", + "stroke": "স্ট্রোক", + "background": "ব্যাকগ্রাউন্ড", + "fill": "ফিল", + "strokeWidth": "স্ট্রোকের পুরুত্ব", + "strokeStyle": "স্ট্রোকের স্টাইল", + "strokeStyle_solid": "সলিড", + "strokeStyle_dashed": "কাটা-কাটা", + "strokeStyle_dotted": "ফোটা-ফোটা", + "sloppiness": "স্ট্রোকের ধরণ", + "opacity": "অস্বচ্ছতা", + "textAlign": "লেখার দিক", + "edges": "কোণা", + "sharp": "তীক্ষ্ণ", + "round": "গোলাকার", + "arrowheads": "তীরের মাথা", + "arrowhead_none": "কিছু না", + "arrowhead_arrow": "তীর", + "arrowhead_bar": "বার", + "arrowhead_dot": "ডট", + "arrowhead_triangle": "ত্রিভুজ", + "fontSize": "ফন্ট সাইজ", + "fontFamily": "ফন্ট ফ্যামিলি", + "onlySelected": "শুধুমাত্র সিলেক্টেডগুলো", + "withBackground": "ব্যাকগ্রাউন্ড", + "exportEmbedScene": "সিন এম্বেড করুন", + "exportEmbedScene_details": "সিনের ডেটা এক্সপোর্টকৃত PNG/SVG ফাইলের মধ্যে সেভ করা হবে যাতে করে পরবর্তী সময়ে আপনি এডিট করতে পারেন । তবে এতে ফাইলের সাইজ বাড়বে ।.", "addWatermark": "", - "handDrawn": "", - "normal": "", - "code": "", - "small": "", - "medium": "", - "large": "", + "handDrawn": "হাতে আঁকা", + "normal": "স্বাভাবিক", + "code": "কোড", + "small": "ছোট", + "medium": "মধ্যবর্তী", + "large": "বড়", "veryLarge": "", "solid": "", "hachure": "", @@ -99,7 +99,7 @@ "flipVertical": "", "viewMode": "", "toggleExportColorScheme": "", - "share": "", + "share": "শেয়ার করুন", "showStroke": "", "showBackground": "", "toggleTheme": "", diff --git a/src/locales/lt-LT.json b/src/locales/lt-LT.json index cc75b9747..c7afc65eb 100644 --- a/src/locales/lt-LT.json +++ b/src/locales/lt-LT.json @@ -110,13 +110,13 @@ "unbindText": "", "bindText": "", "link": { - "edit": "", - "create": "", - "label": "" + "edit": "Redeguoti nuorodą", + "create": "Sukurti nuorodą", + "label": "Nuoroda" }, "elementLock": { - "lock": "", - "unlock": "", + "lock": "Užrakinti", + "unlock": "Atrakinti", "lockAll": "", "unlockAll": "" }, diff --git a/src/locales/percentages.json b/src/locales/percentages.json index 5f078434f..bdb04fcac 100644 --- a/src/locales/percentages.json +++ b/src/locales/percentages.json @@ -1,7 +1,7 @@ { "ar-SA": 91, "bg-BG": 58, - "bn-BD": 0, + "bn-BD": 13, "ca-ES": 99, "cs-CZ": 27, "da-DK": 34, @@ -23,7 +23,7 @@ "kab-KAB": 95, "kk-KZ": 22, "ko-KR": 99, - "lt-LT": 22, + "lt-LT": 24, "lv-LV": 100, "mr-IN": 100, "my-MM": 44, @@ -44,7 +44,7 @@ "ta-IN": 98, "tr-TR": 99, "uk-UA": 100, - "vi-VN": 13, + "vi-VN": 16, "zh-CN": 100, "zh-HK": 27, "zh-TW": 100 diff --git a/src/locales/vi-VN.json b/src/locales/vi-VN.json index ba3b2ecff..0aa55fa3a 100644 --- a/src/locales/vi-VN.json +++ b/src/locales/vi-VN.json @@ -1,10 +1,10 @@ { "labels": { "paste": "Dán", - "pasteCharts": "", + "pasteCharts": "Dán biểu đồ", "selectAll": "Chọn tất cả", - "multiSelect": "", - "moveCanvas": "", + "multiSelect": "Thêm mới vào Select", + "moveCanvas": "Di chuyển Canvas", "cut": "Cắt", "copy": "Sao chép", "copyAsPng": "Sao chép vào bộ nhớ tạm dưới dạng PNG", @@ -43,22 +43,22 @@ "withBackground": "Nền", "exportEmbedScene": "", "exportEmbedScene_details": "", - "addWatermark": "", + "addWatermark": "Làm với Excalidraw\"", "handDrawn": "", "normal": "Bình thường", "code": "Mã", "small": "Nhỏ", "medium": "Vừa", "large": "Lớn", - "veryLarge": "", - "solid": "", + "veryLarge": "Rất lớn", + "solid": "Đặc", "hachure": "", "crossHatch": "", - "thin": "", - "bold": "", - "left": "", - "center": "", - "right": "", + "thin": "Mỏng", + "bold": "In đậm", + "left": "Trái", + "center": "Giữa", + "right": "Phải", "extraBold": "", "architect": "", "artist": "", From b3052f017889e146869c0a48eda377795692737b Mon Sep 17 00:00:00 2001 From: Abdullah Adeel <64294045+mabdullahadeel@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:11:44 +0500 Subject: [PATCH 11/11] fix: #5622 - prevent session theme reset during collaboration (#5640) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✅ fixed #5622 - prevent session theme reset - ❌ prevent newly initialized state to override theme preferences. - 🔧 fix for #5622 * refactor Co-authored-by: Aakansha Doshi --- src/excalidraw-app/index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/excalidraw-app/index.tsx b/src/excalidraw-app/index.tsx index 896c96d98..ebe6ed8eb 100644 --- a/src/excalidraw-app/index.tsx +++ b/src/excalidraw-app/index.tsx @@ -194,7 +194,13 @@ const initializeScene = async (opts: { scene: { ...scene, appState: { - ...restoreAppState(scene?.appState, excalidrawAPI.getAppState()), + ...restoreAppState( + { + ...scene?.appState, + theme: localDataState?.appState?.theme || scene?.appState?.theme, + }, + excalidrawAPI.getAppState(), + ), // necessary if we're invoking from a hashchange handler which doesn't // go through App.initializeScene() that resets this flag isLoading: false,