drawboard-microservice 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -0
- package/dist/index.js +41234 -0
- package/package.json +14 -4
- package/dist-app/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist-app/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist-app/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist-app/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist-app/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist-app/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist-app/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist-app/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist-app/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist-app/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist-app/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist-app/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist-app/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist-app/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist-app/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist-app/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist-app/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist-app/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist-app/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist-app/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist-app/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist-app/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist-app/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist-app/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist-app/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist-app/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist-app/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist-app/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist-app/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist-app/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist-app/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist-app/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist-app/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist-app/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist-app/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist-app/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist-app/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist-app/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist-app/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist-app/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist-app/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist-app/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist-app/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist-app/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist-app/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist-app/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist-app/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist-app/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist-app/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist-app/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist-app/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist-app/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist-app/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist-app/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist-app/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist-app/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist-app/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist-app/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist-app/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist-app/assets/index-DxkNA4rg.js +0 -307
- package/dist-app/assets/index-DxkNA4rg.js.map +0 -1
- package/dist-app/assets/index-uvzSCXM2.css +0 -1
- package/dist-app/index.html +0 -13
- package/dockerfile +0 -14
- package/eslint.config.js +0 -23
- package/index.html +0 -12
- package/public/icon-align-64-default.png +0 -0
- package/public/icon-align-justify-64-active.png +0 -0
- package/public/icon-align-justify-64-default 1.png +0 -0
- package/public/icon-align-justify-64-default.png +0 -0
- package/public/icon-align-justify-64-hover.png +0 -0
- package/public/icon-align-left-64-active.png +0 -0
- package/public/icon-align-left-64-default 1.png +0 -0
- package/public/icon-align-left-64-default.png +0 -0
- package/public/icon-align-left-64-hover.png +0 -0
- package/public/icon-align-right-64-active.png +0 -0
- package/public/icon-align-right-64-default.png +0 -0
- package/public/icon-align-right-64-hover.png +0 -0
- package/public/icon-bold-64-active.png +0 -0
- package/public/icon-bold-64-default 1.png +0 -0
- package/public/icon-bold-64-default.png +0 -0
- package/public/icon-bold-64-hover.png +0 -0
- package/public/icon-broom-64-active.png +0 -0
- package/public/icon-broom-64-default.png +0 -0
- package/public/icon-broom-64-hover.png +0 -0
- package/public/icon-cancel-64-active.png +0 -0
- package/public/icon-cancel-64-default.png +0 -0
- package/public/icon-cancel-64-hover.png +0 -0
- package/public/icon-change-64-active.png +0 -0
- package/public/icon-change-64-default.png +0 -0
- package/public/icon-change-64-hover.png +0 -0
- package/public/icon-circle-64-active.png +0 -0
- package/public/icon-circle-64-default.png +0 -0
- package/public/icon-circle-64-hover.png +0 -0
- package/public/icon-close-64-active.png +0 -0
- package/public/icon-close-64-default.png +0 -0
- package/public/icon-close-64-hover.png +0 -0
- package/public/icon-cursor-64-active.png +0 -0
- package/public/icon-cursor-64-default.png +0 -0
- package/public/icon-cursor-64-hover.png +0 -0
- package/public/icon-delete-trash-64-active.png +0 -0
- package/public/icon-delete-trash-64-default.png +0 -0
- package/public/icon-delete-trash-64-hover.png +0 -0
- package/public/icon-done-64-active.png +0 -0
- package/public/icon-done-64-default.png +0 -0
- package/public/icon-done-64-hover.png +0 -0
- package/public/icon-edit-text-file-64-active.png +0 -0
- package/public/icon-edit-text-file-64-default 1.png +0 -0
- package/public/icon-edit-text-file-64-default.png +0 -0
- package/public/icon-edit-text-file-64-hover.png +0 -0
- package/public/icon-eraser-64-active.png +0 -0
- package/public/icon-eraser-64-default.png +0 -0
- package/public/icon-eraser-64-hover.png +0 -0
- package/public/icon-font-style-64-active.png +0 -0
- package/public/icon-font-style-64-default.png +0 -0
- package/public/icon-font-style-64-hover.png +0 -0
- package/public/icon-formula-fx-64-active.png +0 -0
- package/public/icon-formula-fx-64-default.png +0 -0
- package/public/icon-formula-fx-64-hover.png +0 -0
- package/public/icon-highlighter-64-active.png +0 -0
- package/public/icon-highlighter-64-default.png +0 -0
- package/public/icon-highlighter-64-hover.png +0 -0
- package/public/icon-installing-64-active.png +0 -0
- package/public/icon-installing-64-default.png +0 -0
- package/public/icon-installing-64-hover.png +0 -0
- package/public/icon-italic-64-active.png +0 -0
- package/public/icon-italic-64-default 1.png +0 -0
- package/public/icon-italic-64-default.png +0 -0
- package/public/icon-italic-64-hover.png +0 -0
- package/public/icon-line-64-active.png +0 -0
- package/public/icon-line-64-default.png +0 -0
- package/public/icon-line-64-hover.png +0 -0
- package/public/icon-pen-64-active.png +0 -0
- package/public/icon-pen-64-default.png +0 -0
- package/public/icon-pen-64-hover.png +0 -0
- package/public/icon-pin-64-active.png +0 -0
- package/public/icon-pin-64-default.png +0 -0
- package/public/icon-pin-64-hover.png +0 -0
- package/public/icon-redo-64-active.png +0 -0
- package/public/icon-redo-64-default.png +0 -0
- package/public/icon-redo-64-hover.png +0 -0
- package/public/icon-return-64-active.png +0 -0
- package/public/icon-return-64-default.png +0 -0
- package/public/icon-return-64-hover.png +0 -0
- package/public/icon-select-active.png +0 -0
- package/public/icon-select-default.png +0 -0
- package/public/icon-select-hover.png +0 -0
- package/public/icon-square-64-active.png +0 -0
- package/public/icon-square-64-default.png +0 -0
- package/public/icon-square-64-hover.png +0 -0
- package/public/icon-strikethrough-64-active.png +0 -0
- package/public/icon-strikethrough-64-default 1.png +0 -0
- package/public/icon-strikethrough-64-default.png +0 -0
- package/public/icon-strikethrough-64-hover.png +0 -0
- package/public/icon-text-64-active.png +0 -0
- package/public/icon-text-64-default.png +0 -0
- package/public/icon-text-64-hover.png +0 -0
- package/public/icon-u-turn-to-right-64-active.png +0 -0
- package/public/icon-u-turn-to-right-64-default.png +0 -0
- package/public/icon-u-turn-to-right-64-hover.png +0 -0
- package/public/icon-under-64-active.png +0 -0
- package/public/icon-under-64-default 1.png +0 -0
- package/public/icon-under-64-default.png +0 -0
- package/public/icon-under-64-hover.png +0 -0
- package/src/App.css +0 -887
- package/src/App.tsx +0 -1468
- package/src/assets/icon-broom-64-active.png +0 -0
- package/src/assets/icon-broom-64-default.png +0 -0
- package/src/assets/icon-broom-64-hover.png +0 -0
- package/src/assets/icon-cancel-64-active.png +0 -0
- package/src/assets/icon-cancel-64-default.png +0 -0
- package/src/assets/icon-cancel-64-hover.png +0 -0
- package/src/assets/icon-change-64-active.png +0 -0
- package/src/assets/icon-change-64-default.png +0 -0
- package/src/assets/icon-change-64-hover.png +0 -0
- package/src/assets/icon-circle-64-active.png +0 -0
- package/src/assets/icon-circle-64-default.png +0 -0
- package/src/assets/icon-circle-64-hover.png +0 -0
- package/src/assets/icon-cursor-64-active.png +0 -0
- package/src/assets/icon-cursor-64-default.png +0 -0
- package/src/assets/icon-cursor-64-hover.png +0 -0
- package/src/assets/icon-delete-trash-64-active.png +0 -0
- package/src/assets/icon-delete-trash-64-default.png +0 -0
- package/src/assets/icon-delete-trash-64-hover.png +0 -0
- package/src/assets/icon-eraser-64-active.png +0 -0
- package/src/assets/icon-eraser-64-default.png +0 -0
- package/src/assets/icon-eraser-64-hover.png +0 -0
- package/src/assets/icon-font-style-64-active.png +0 -0
- package/src/assets/icon-font-style-64-default.png +0 -0
- package/src/assets/icon-font-style-64-hover.png +0 -0
- package/src/assets/icon-formula-fx-64-active.png +0 -0
- package/src/assets/icon-formula-fx-64-default.png +0 -0
- package/src/assets/icon-formula-fx-64-hover.png +0 -0
- package/src/assets/icon-highlighter-64-active.png +0 -0
- package/src/assets/icon-highlighter-64-default.png +0 -0
- package/src/assets/icon-highlighter-64-hover.png +0 -0
- package/src/assets/icon-installing-64-active.png +0 -0
- package/src/assets/icon-installing-64-default.png +0 -0
- package/src/assets/icon-installing-64-hover.png +0 -0
- package/src/assets/icon-line-64-active.png +0 -0
- package/src/assets/icon-line-64-default.png +0 -0
- package/src/assets/icon-line-64-hover.png +0 -0
- package/src/assets/icon-minus-64-active.png +0 -0
- package/src/assets/icon-minus-64-default.png +0 -0
- package/src/assets/icon-minus-64-hover.png +0 -0
- package/src/assets/icon-pen-64-active.png +0 -0
- package/src/assets/icon-pen-64-default.png +0 -0
- package/src/assets/icon-pen-64-hover.png +0 -0
- package/src/assets/icon-pin-64-active.png +0 -0
- package/src/assets/icon-pin-64-default.png +0 -0
- package/src/assets/icon-pin-64-hover.png +0 -0
- package/src/assets/icon-plus-64-active.png +0 -0
- package/src/assets/icon-plus-64-default.png +0 -0
- package/src/assets/icon-plus-64-hover.png +0 -0
- package/src/assets/icon-return-64-active.png +0 -0
- package/src/assets/icon-return-64-default.png +0 -0
- package/src/assets/icon-return-64-hover.png +0 -0
- package/src/assets/icon-select-active.png +0 -0
- package/src/assets/icon-select-default.png +0 -0
- package/src/assets/icon-select-hover.png +0 -0
- package/src/assets/icon-square-64-active.png +0 -0
- package/src/assets/icon-square-64-default.png +0 -0
- package/src/assets/icon-square-64-hover.png +0 -0
- package/src/assets/icon-text-64-active.png +0 -0
- package/src/assets/icon-text-64-default.png +0 -0
- package/src/assets/icon-text-64-hover.png +0 -0
- package/src/assets/icon-u-turn-to-right-64-active.png +0 -0
- package/src/assets/icon-u-turn-to-right-64-default.png +0 -0
- package/src/assets/icon-u-turn-to-right-64-hover.png +0 -0
- package/src/components/BrushToolbar.tsx +0 -72
- package/src/components/LatexEditor.tsx +0 -247
- package/src/components/LatexToolbar.tsx +0 -68
- package/src/components/OCRPreview.tsx +0 -234
- package/src/components/OCRToolbar.tsx +0 -46
- package/src/components/RangeToolbar.tsx +0 -33
- package/src/components/SelDelToolbar.tsx +0 -52
- package/src/components/TextEditor.tsx +0 -38
- package/src/components/TextToolbar.tsx +0 -271
- package/src/components/ToolsToolbar.tsx +0 -114
- package/src/constants/fonts.ts +0 -14
- package/src/constants/latexCategories.ts +0 -11
- package/src/constants/latexSymbols.ts +0 -38
- package/src/hooks/useDrawingHandlers.ts +0 -675
- package/src/hooks/useDrawingState.ts +0 -59
- package/src/hooks/useHistory.ts +0 -52
- package/src/hooks/useKeyboard.ts +0 -96
- package/src/hooks/useLatexSymbols.ts +0 -79
- package/src/hooks/useOutsideClick.ts +0 -25
- package/src/hooks/useTextEditing.ts +0 -131
- package/src/hooks/useTextFormatting.ts +0 -153
- package/src/hooks/useWebSocket.ts +0 -202
- package/src/index.ts +0 -4
- package/src/main.tsx +0 -18
- package/src/services/api.ts +0 -81
- package/src/services/statsService.ts +0 -165
- package/src/services/widgetBridge.ts +0 -73
- package/src/types.ts +0 -80
- package/src/utils/colorUtils.ts +0 -6
- package/src/utils/latexUtils.ts +0 -48
- package/src/utils/shapeUtils.ts +0 -151
- package/tsconfig.app.json +0 -28
- package/tsconfig.json +0 -14
- package/tsconfig.node.json +0 -26
- package/vite.config.ts +0 -84
- /package/{dist-app → dist}/icon-align-64-default.png +0 -0
- /package/{dist-app → dist}/icon-align-justify-64-active.png +0 -0
- /package/{dist-app → dist}/icon-align-justify-64-default 1.png +0 -0
- /package/{dist-app → dist}/icon-align-justify-64-default.png +0 -0
- /package/{dist-app → dist}/icon-align-justify-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-align-left-64-active.png +0 -0
- /package/{dist-app → dist}/icon-align-left-64-default 1.png +0 -0
- /package/{dist-app → dist}/icon-align-left-64-default.png +0 -0
- /package/{dist-app → dist}/icon-align-left-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-align-right-64-active.png +0 -0
- /package/{dist-app → dist}/icon-align-right-64-default.png +0 -0
- /package/{dist-app → dist}/icon-align-right-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-bold-64-active.png +0 -0
- /package/{dist-app → dist}/icon-bold-64-default 1.png +0 -0
- /package/{dist-app → dist}/icon-bold-64-default.png +0 -0
- /package/{dist-app → dist}/icon-bold-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-broom-64-active.png +0 -0
- /package/{dist-app → dist}/icon-broom-64-default.png +0 -0
- /package/{dist-app → dist}/icon-broom-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-cancel-64-active.png +0 -0
- /package/{dist-app → dist}/icon-cancel-64-default.png +0 -0
- /package/{dist-app → dist}/icon-cancel-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-change-64-active.png +0 -0
- /package/{dist-app → dist}/icon-change-64-default.png +0 -0
- /package/{dist-app → dist}/icon-change-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-circle-64-active.png +0 -0
- /package/{dist-app → dist}/icon-circle-64-default.png +0 -0
- /package/{dist-app → dist}/icon-circle-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-close-64-active.png +0 -0
- /package/{dist-app → dist}/icon-close-64-default.png +0 -0
- /package/{dist-app → dist}/icon-close-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-cursor-64-active.png +0 -0
- /package/{dist-app → dist}/icon-cursor-64-default.png +0 -0
- /package/{dist-app → dist}/icon-cursor-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-delete-trash-64-active.png +0 -0
- /package/{dist-app → dist}/icon-delete-trash-64-default.png +0 -0
- /package/{dist-app → dist}/icon-delete-trash-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-done-64-active.png +0 -0
- /package/{dist-app → dist}/icon-done-64-default.png +0 -0
- /package/{dist-app → dist}/icon-done-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-edit-text-file-64-active.png +0 -0
- /package/{dist-app → dist}/icon-edit-text-file-64-default 1.png +0 -0
- /package/{dist-app → dist}/icon-edit-text-file-64-default.png +0 -0
- /package/{dist-app → dist}/icon-edit-text-file-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-eraser-64-active.png +0 -0
- /package/{dist-app → dist}/icon-eraser-64-default.png +0 -0
- /package/{dist-app → dist}/icon-eraser-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-font-style-64-active.png +0 -0
- /package/{dist-app → dist}/icon-font-style-64-default.png +0 -0
- /package/{dist-app → dist}/icon-font-style-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-formula-fx-64-active.png +0 -0
- /package/{dist-app → dist}/icon-formula-fx-64-default.png +0 -0
- /package/{dist-app → dist}/icon-formula-fx-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-highlighter-64-active.png +0 -0
- /package/{dist-app → dist}/icon-highlighter-64-default.png +0 -0
- /package/{dist-app → dist}/icon-highlighter-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-installing-64-active.png +0 -0
- /package/{dist-app → dist}/icon-installing-64-default.png +0 -0
- /package/{dist-app → dist}/icon-installing-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-italic-64-active.png +0 -0
- /package/{dist-app → dist}/icon-italic-64-default 1.png +0 -0
- /package/{dist-app → dist}/icon-italic-64-default.png +0 -0
- /package/{dist-app → dist}/icon-italic-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-line-64-active.png +0 -0
- /package/{dist-app → dist}/icon-line-64-default.png +0 -0
- /package/{dist-app → dist}/icon-line-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-pen-64-active.png +0 -0
- /package/{dist-app → dist}/icon-pen-64-default.png +0 -0
- /package/{dist-app → dist}/icon-pen-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-pin-64-active.png +0 -0
- /package/{dist-app → dist}/icon-pin-64-default.png +0 -0
- /package/{dist-app → dist}/icon-pin-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-redo-64-active.png +0 -0
- /package/{dist-app → dist}/icon-redo-64-default.png +0 -0
- /package/{dist-app → dist}/icon-redo-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-return-64-active.png +0 -0
- /package/{dist-app → dist}/icon-return-64-default.png +0 -0
- /package/{dist-app → dist}/icon-return-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-select-active.png +0 -0
- /package/{dist-app → dist}/icon-select-default.png +0 -0
- /package/{dist-app → dist}/icon-select-hover.png +0 -0
- /package/{dist-app → dist}/icon-square-64-active.png +0 -0
- /package/{dist-app → dist}/icon-square-64-default.png +0 -0
- /package/{dist-app → dist}/icon-square-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-strikethrough-64-active.png +0 -0
- /package/{dist-app → dist}/icon-strikethrough-64-default 1.png +0 -0
- /package/{dist-app → dist}/icon-strikethrough-64-default.png +0 -0
- /package/{dist-app → dist}/icon-strikethrough-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-text-64-active.png +0 -0
- /package/{dist-app → dist}/icon-text-64-default.png +0 -0
- /package/{dist-app → dist}/icon-text-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-u-turn-to-right-64-active.png +0 -0
- /package/{dist-app → dist}/icon-u-turn-to-right-64-default.png +0 -0
- /package/{dist-app → dist}/icon-u-turn-to-right-64-hover.png +0 -0
- /package/{dist-app → dist}/icon-under-64-active.png +0 -0
- /package/{dist-app → dist}/icon-under-64-default 1.png +0 -0
- /package/{dist-app → dist}/icon-under-64-default.png +0 -0
- /package/{dist-app → dist}/icon-under-64-hover.png +0 -0
|
@@ -1,675 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
import { useCallback, useState } from 'react';
|
|
3
|
-
import type { Shape, DrawingState, TransformState, ToolMode, ShapeType } from '../types';
|
|
4
|
-
import { calculateBoundingBox, isPointInShape, transformPoints } from '../utils/shapeUtils';
|
|
5
|
-
import { measureLatexSize, renderLatexToHtml } from '../utils/latexUtils';
|
|
6
|
-
|
|
7
|
-
export const useDrawingHandlers = (
|
|
8
|
-
shapes: Shape[],
|
|
9
|
-
setShapes: React.Dispatch<React.SetStateAction<Shape[]>>,
|
|
10
|
-
saveToHistory: (shapes: Shape[]) => void,
|
|
11
|
-
tool: ToolMode,
|
|
12
|
-
strokeColor: string,
|
|
13
|
-
strokeWidth: number,
|
|
14
|
-
fontSize: number,
|
|
15
|
-
fontFamily: string,
|
|
16
|
-
textAlign: 'left' | 'center' | 'right',
|
|
17
|
-
selectedId: string | null,
|
|
18
|
-
setSelectedId: React.Dispatch<React.SetStateAction<string | null>>,
|
|
19
|
-
setDrawingState: React.Dispatch<React.SetStateAction<DrawingState>>,
|
|
20
|
-
setTransformState: React.Dispatch<React.SetStateAction<TransformState>>,
|
|
21
|
-
startTextEditing: (id: string) => void,
|
|
22
|
-
scale: number,
|
|
23
|
-
ocrSelection: any,
|
|
24
|
-
setOcrSelection: React.Dispatch<React.SetStateAction<any>>,
|
|
25
|
-
clearOcrBorders: () => void
|
|
26
|
-
) => {
|
|
27
|
-
const [isDragging, setIsDragging] = useState(false);
|
|
28
|
-
const [dragStart, setDragStart] = useState({ x: 0, y: 0 });
|
|
29
|
-
const [selectedShapeStart, setSelectedShapeStart] = useState({ x: 0, y: 0 });
|
|
30
|
-
const [originalPointsOnDragStart, setOriginalPointsOnDragStart] = useState<number[]>([]);
|
|
31
|
-
const [erasedShapes, setErasedShapes] = useState<Set<string>>(new Set());
|
|
32
|
-
const [eraserHistoryStart, setEraserHistoryStart] = useState<Shape[] | null>(null);
|
|
33
|
-
|
|
34
|
-
const constrainToCanvas = useCallback((x: number, y: number, width: number, height: number) => {
|
|
35
|
-
const canvasWidth = 6000;
|
|
36
|
-
const canvasHeight = 2500;
|
|
37
|
-
|
|
38
|
-
const realX = width >= 0 ? x : x + width;
|
|
39
|
-
const realY = height >= 0 ? y : y + height;
|
|
40
|
-
const realWidth = Math.abs(width);
|
|
41
|
-
const realHeight = Math.abs(height);
|
|
42
|
-
|
|
43
|
-
const constrainedRealX = Math.max(0, Math.min(realX, canvasWidth - realWidth));
|
|
44
|
-
const constrainedRealY = Math.max(0, Math.min(realY, canvasHeight - realHeight));
|
|
45
|
-
|
|
46
|
-
let finalX = constrainedRealX;
|
|
47
|
-
let finalY = constrainedRealY;
|
|
48
|
-
let finalWidth = width;
|
|
49
|
-
let finalHeight = height;
|
|
50
|
-
|
|
51
|
-
if (width < 0) {
|
|
52
|
-
finalX = constrainedRealX - realWidth;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (height < 0) {
|
|
56
|
-
finalY = constrainedRealY - realHeight;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return { x: finalX, y: finalY, width: finalWidth, height: finalHeight };
|
|
60
|
-
}, []);
|
|
61
|
-
|
|
62
|
-
const handleMouseDown = useCallback((e: any) => {
|
|
63
|
-
const stage = e.target.getStage();
|
|
64
|
-
const pos = stage.getPointerPosition();
|
|
65
|
-
const container = stage.container();
|
|
66
|
-
const adjustedX = (pos.x / scale) + (container.scrollLeft / scale);
|
|
67
|
-
const adjustedY = (pos.y / scale) + (container.scrollTop / scale);
|
|
68
|
-
const adjustedPos = { x: adjustedX, y: adjustedY };
|
|
69
|
-
|
|
70
|
-
if (adjustedPos.x < 0 || adjustedPos.x > 6000 || adjustedPos.y < 0 || adjustedPos.y > 2500) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (e.target.attrs.name && e.target.attrs.name.startsWith('anchor-')) {
|
|
75
|
-
const shapeId = e.target.attrs.shapeId;
|
|
76
|
-
const shape = shapes.find(s => s.id === shapeId);
|
|
77
|
-
if (shape && tool === 'select') {
|
|
78
|
-
const anchor = e.target.attrs.name.replace('anchor-', '') as 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
79
|
-
|
|
80
|
-
let originalPoints = shape.points;
|
|
81
|
-
let originalBbox = { x: shape.x, y: shape.y, width: shape.width, height: shape.height };
|
|
82
|
-
|
|
83
|
-
if ((shape.type === 'path' || shape.type === 'line' || shape.type === 'highlighter') && shape.points) {
|
|
84
|
-
originalPoints = [...shape.points];
|
|
85
|
-
const bbox = calculateBoundingBox(shape.points);
|
|
86
|
-
originalBbox = bbox;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
setTransformState({
|
|
90
|
-
isTransforming: true,
|
|
91
|
-
shapeId,
|
|
92
|
-
startWidth: shape.width,
|
|
93
|
-
startHeight: shape.height,
|
|
94
|
-
startX: shape.x,
|
|
95
|
-
startY: shape.y,
|
|
96
|
-
startMouseX: adjustedPos.x,
|
|
97
|
-
startMouseY: adjustedPos.y,
|
|
98
|
-
anchor,
|
|
99
|
-
originalPoints,
|
|
100
|
-
originalBbox,
|
|
101
|
-
startFontSize: shape.fontSize || fontSize
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (e.target === stage) {
|
|
108
|
-
if (tool === 'select') {
|
|
109
|
-
setSelectedId(null);
|
|
110
|
-
setShapes(shapes.map(shape => ({ ...shape, isSelected: false, isEditing: false })));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (tool === 'ocr-selection') {
|
|
114
|
-
// Очищаем предыдущие OCR границы с холста
|
|
115
|
-
clearOcrBorders();
|
|
116
|
-
setOcrSelection(null);
|
|
117
|
-
|
|
118
|
-
setDrawingState({
|
|
119
|
-
isDrawing: true,
|
|
120
|
-
startX: adjustedX,
|
|
121
|
-
startY: adjustedY,
|
|
122
|
-
currentShape: {
|
|
123
|
-
id: `ocr_${Date.now()}`,
|
|
124
|
-
type: 'rectangle',
|
|
125
|
-
x: adjustedX,
|
|
126
|
-
y: adjustedY,
|
|
127
|
-
width: 0,
|
|
128
|
-
height: 0,
|
|
129
|
-
stroke: '#007bff',
|
|
130
|
-
strokeWidth: 2,
|
|
131
|
-
dash: [5, 5],
|
|
132
|
-
opacity: 1
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (tool === 'text' || tool === 'latex') {
|
|
139
|
-
const isLatex = tool === 'latex';
|
|
140
|
-
let initialText = isLatex ? 'E = mc^2' : 'Text';
|
|
141
|
-
const currentFontSize = fontSize;
|
|
142
|
-
|
|
143
|
-
let newTextShape: Shape;
|
|
144
|
-
|
|
145
|
-
if (isLatex) {
|
|
146
|
-
const size = measureLatexSize(initialText, currentFontSize);
|
|
147
|
-
newTextShape = {
|
|
148
|
-
id: `${isLatex ? 'latex' : 'text'}_${Date.now()}`,
|
|
149
|
-
type: isLatex ? 'latex' : 'text',
|
|
150
|
-
x: adjustedX,
|
|
151
|
-
y: adjustedY,
|
|
152
|
-
width: size.width,
|
|
153
|
-
height: size.height,
|
|
154
|
-
stroke: strokeColor,
|
|
155
|
-
strokeWidth: 1,
|
|
156
|
-
text: isLatex ? '' : 'Text',
|
|
157
|
-
latex: isLatex ? initialText : undefined,
|
|
158
|
-
latexRendered: isLatex ? renderLatexToHtml(initialText, currentFontSize) : undefined,
|
|
159
|
-
fontSize: currentFontSize,
|
|
160
|
-
fontFamily: fontFamily,
|
|
161
|
-
textAlign: textAlign,
|
|
162
|
-
fontWeight: 'normal',
|
|
163
|
-
fontStyle: 'normal',
|
|
164
|
-
textDecoration: 'none',
|
|
165
|
-
isSelected: true,
|
|
166
|
-
isEditing: false,
|
|
167
|
-
isLatex: isLatex,
|
|
168
|
-
scaleX: 1,
|
|
169
|
-
scaleY: 1,
|
|
170
|
-
rotation: 0
|
|
171
|
-
};
|
|
172
|
-
} else {
|
|
173
|
-
const lineHeight = currentFontSize;
|
|
174
|
-
const lines = initialText.split('\n').length || 1;
|
|
175
|
-
const height = Math.max(lines * lineHeight * 1.2, 50);
|
|
176
|
-
|
|
177
|
-
newTextShape = {
|
|
178
|
-
id: `${isLatex ? 'latex' : 'text'}_${Date.now()}`,
|
|
179
|
-
type: isLatex ? 'latex' : 'text',
|
|
180
|
-
x: adjustedX,
|
|
181
|
-
y: adjustedY,
|
|
182
|
-
width: 200,
|
|
183
|
-
height: height,
|
|
184
|
-
stroke: strokeColor,
|
|
185
|
-
strokeWidth: 1,
|
|
186
|
-
text: initialText,
|
|
187
|
-
latex: undefined,
|
|
188
|
-
latexRendered: undefined,
|
|
189
|
-
fontSize: currentFontSize,
|
|
190
|
-
fontFamily: fontFamily,
|
|
191
|
-
textAlign: textAlign,
|
|
192
|
-
fontWeight: 'normal',
|
|
193
|
-
fontStyle: 'normal',
|
|
194
|
-
textDecoration: 'none',
|
|
195
|
-
isSelected: true,
|
|
196
|
-
isEditing: false,
|
|
197
|
-
isLatex: isLatex,
|
|
198
|
-
scaleX: 1,
|
|
199
|
-
scaleY: 1,
|
|
200
|
-
rotation: 0
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (isLatex) {
|
|
205
|
-
const constrained = constrainToCanvas(newTextShape.x, newTextShape.y, newTextShape.width, newTextShape.height);
|
|
206
|
-
newTextShape.x = constrained.x;
|
|
207
|
-
newTextShape.y = constrained.y;
|
|
208
|
-
newTextShape.width = constrained.width;
|
|
209
|
-
newTextShape.height = constrained.height;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const newShapes = [...shapes, newTextShape];
|
|
213
|
-
setShapes(newShapes);
|
|
214
|
-
saveToHistory(newShapes);
|
|
215
|
-
|
|
216
|
-
setTimeout(() => {
|
|
217
|
-
startTextEditing(newTextShape.id);
|
|
218
|
-
}, 10);
|
|
219
|
-
}
|
|
220
|
-
else if (tool === 'eraser') {
|
|
221
|
-
setEraserHistoryStart([...shapes]);
|
|
222
|
-
|
|
223
|
-
const newErasedShapes = new Set<string>();
|
|
224
|
-
shapes.forEach(shape => {
|
|
225
|
-
if (isPointInShape(shape, adjustedPos)) {
|
|
226
|
-
newErasedShapes.add(shape.id);
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
if (newErasedShapes.size > 0) {
|
|
231
|
-
const newShapes = shapes.filter(shape => !newErasedShapes.has(shape.id));
|
|
232
|
-
setShapes(newShapes);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
setErasedShapes(newErasedShapes);
|
|
236
|
-
|
|
237
|
-
setDrawingState({
|
|
238
|
-
isDrawing: true,
|
|
239
|
-
startX: adjustedX,
|
|
240
|
-
startY: adjustedY,
|
|
241
|
-
currentShape: {
|
|
242
|
-
id: `eraser_${Date.now()}`,
|
|
243
|
-
type: 'path',
|
|
244
|
-
x: adjustedX,
|
|
245
|
-
y: adjustedY,
|
|
246
|
-
width: 0,
|
|
247
|
-
height: 0,
|
|
248
|
-
stroke: '#000000',
|
|
249
|
-
strokeWidth: strokeWidth,
|
|
250
|
-
opacity: 1,
|
|
251
|
-
points: [adjustedX, adjustedY]
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
else if (!['select', 'text', 'latex'].includes(tool)) {
|
|
256
|
-
const shapeType = tool === 'pencil' ? 'path' : tool === 'highlighter' ? 'highlighter' : tool as ShapeType;
|
|
257
|
-
|
|
258
|
-
setDrawingState({
|
|
259
|
-
isDrawing: true,
|
|
260
|
-
startX: adjustedX,
|
|
261
|
-
startY: adjustedY,
|
|
262
|
-
currentShape: {
|
|
263
|
-
id: `${tool}_${Date.now()}`,
|
|
264
|
-
type: shapeType,
|
|
265
|
-
x: adjustedX,
|
|
266
|
-
y: adjustedY,
|
|
267
|
-
width: 0,
|
|
268
|
-
height: 0,
|
|
269
|
-
stroke: strokeColor,
|
|
270
|
-
strokeWidth: strokeWidth,
|
|
271
|
-
opacity: tool === 'highlighter' ? 0.5 : 1,
|
|
272
|
-
points: (tool === 'pencil' || tool === 'highlighter') ? [adjustedX, adjustedY] : undefined
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (tool === 'select' && e.target.attrs.id) {
|
|
280
|
-
const targetId = e.target.attrs.id;
|
|
281
|
-
const shape = shapes.find(s => s.id === targetId);
|
|
282
|
-
|
|
283
|
-
if (shape) {
|
|
284
|
-
setSelectedId(targetId);
|
|
285
|
-
|
|
286
|
-
if ((shape.type === 'text' || shape.type === 'latex') && e.evt.detail === 2) {
|
|
287
|
-
startTextEditing(targetId);
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
setIsDragging(true);
|
|
292
|
-
setDragStart({ x: adjustedPos.x, y: adjustedPos.y });
|
|
293
|
-
setSelectedShapeStart({ x: shape.x, y: shape.y });
|
|
294
|
-
|
|
295
|
-
if ((shape.type === 'path' || shape.type === 'line' || shape.type === 'highlighter') && shape.points) {
|
|
296
|
-
setOriginalPointsOnDragStart([...shape.points]);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
setShapes(shapes.map(s => ({
|
|
300
|
-
...s,
|
|
301
|
-
isSelected: s.id === targetId,
|
|
302
|
-
isEditing: false
|
|
303
|
-
})));
|
|
304
|
-
}
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (!['select', 'text', 'latex'].includes(tool)) {
|
|
309
|
-
if (tool === 'eraser') {
|
|
310
|
-
setEraserHistoryStart([...shapes]);
|
|
311
|
-
|
|
312
|
-
const newErasedShapes = new Set<string>();
|
|
313
|
-
shapes.forEach(shape => {
|
|
314
|
-
if (isPointInShape(shape, adjustedPos)) {
|
|
315
|
-
newErasedShapes.add(shape.id);
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
if (newErasedShapes.size > 0) {
|
|
320
|
-
const newShapes = shapes.filter(shape => !newErasedShapes.has(shape.id));
|
|
321
|
-
setShapes(newShapes);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
setErasedShapes(newErasedShapes);
|
|
325
|
-
|
|
326
|
-
setDrawingState({
|
|
327
|
-
isDrawing: true,
|
|
328
|
-
startX: adjustedX,
|
|
329
|
-
startY: adjustedY,
|
|
330
|
-
currentShape: {
|
|
331
|
-
id: `eraser_${Date.now()}`,
|
|
332
|
-
type: 'path',
|
|
333
|
-
x: adjustedX,
|
|
334
|
-
y: adjustedY,
|
|
335
|
-
width: 0,
|
|
336
|
-
height: 0,
|
|
337
|
-
stroke: '#000000',
|
|
338
|
-
strokeWidth: strokeWidth,
|
|
339
|
-
opacity: 1,
|
|
340
|
-
points: [adjustedX, adjustedY]
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
} else {
|
|
344
|
-
const shapeType = tool === 'pencil' ? 'path' : tool === 'highlighter' ? 'highlighter' : tool as ShapeType;
|
|
345
|
-
|
|
346
|
-
setDrawingState({
|
|
347
|
-
isDrawing: true,
|
|
348
|
-
startX: adjustedX,
|
|
349
|
-
startY: adjustedY,
|
|
350
|
-
currentShape: {
|
|
351
|
-
id: `${tool}_${Date.now()}`,
|
|
352
|
-
type: shapeType,
|
|
353
|
-
x: adjustedX,
|
|
354
|
-
y: adjustedY,
|
|
355
|
-
width: 0,
|
|
356
|
-
height: 0,
|
|
357
|
-
stroke: strokeColor,
|
|
358
|
-
strokeWidth: strokeWidth,
|
|
359
|
-
opacity: tool === 'highlighter' ? 0.5 : 1,
|
|
360
|
-
points: (tool === 'pencil' || tool === 'highlighter') ? [adjustedX, adjustedY] : undefined
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}, [
|
|
366
|
-
shapes, setShapes, tool, strokeColor, strokeWidth, fontSize, fontFamily, textAlign,
|
|
367
|
-
selectedId, setSelectedId, setDrawingState, setTransformState, startTextEditing, scale,
|
|
368
|
-
ocrSelection, setOcrSelection, constrainToCanvas, clearOcrBorders
|
|
369
|
-
]);
|
|
370
|
-
|
|
371
|
-
const handleMouseMove = useCallback((
|
|
372
|
-
e: any,
|
|
373
|
-
drawingState: DrawingState,
|
|
374
|
-
transformState: TransformState,
|
|
375
|
-
shiftPressed: boolean
|
|
376
|
-
) => {
|
|
377
|
-
const stage = e.target.getStage();
|
|
378
|
-
const pos = stage.getPointerPosition();
|
|
379
|
-
const container = stage.container();
|
|
380
|
-
const adjustedX = (pos.x / scale) + (container.scrollLeft / scale);
|
|
381
|
-
const adjustedY = (pos.y / scale) + (container.scrollTop / scale);
|
|
382
|
-
const adjustedPos = { x: adjustedX, y: adjustedY };
|
|
383
|
-
|
|
384
|
-
if (drawingState.isDrawing && drawingState.currentShape) {
|
|
385
|
-
const { startX, startY, currentShape } = drawingState;
|
|
386
|
-
|
|
387
|
-
if (tool === 'ocr-selection') {
|
|
388
|
-
let width = adjustedPos.x - startX;
|
|
389
|
-
let height = adjustedPos.y - startY;
|
|
390
|
-
|
|
391
|
-
if (shiftPressed) {
|
|
392
|
-
const size = Math.max(Math.abs(width), Math.abs(height));
|
|
393
|
-
width = Math.sign(width) * size;
|
|
394
|
-
height = Math.sign(height) * size;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
let normalizedX = startX;
|
|
398
|
-
let normalizedY = startY;
|
|
399
|
-
let normalizedWidth = width;
|
|
400
|
-
let normalizedHeight = height;
|
|
401
|
-
|
|
402
|
-
if (width < 0) {
|
|
403
|
-
normalizedX = startX + width;
|
|
404
|
-
normalizedWidth = Math.abs(width);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
if (height < 0) {
|
|
408
|
-
normalizedY = startY + height;
|
|
409
|
-
normalizedHeight = Math.abs(height);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
let updatedShape = {
|
|
413
|
-
...currentShape,
|
|
414
|
-
x: normalizedX,
|
|
415
|
-
y: normalizedY,
|
|
416
|
-
width: normalizedWidth,
|
|
417
|
-
height: normalizedHeight
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
setDrawingState(prev => ({ ...prev, currentShape: updatedShape }));
|
|
421
|
-
}
|
|
422
|
-
else if (tool === 'pencil' || tool === 'eraser' || tool === 'highlighter') {
|
|
423
|
-
const updatedShape = {
|
|
424
|
-
...currentShape,
|
|
425
|
-
points: [...(currentShape.points || []), adjustedPos.x, adjustedPos.y]
|
|
426
|
-
};
|
|
427
|
-
setDrawingState(prev => ({ ...prev, currentShape: updatedShape }));
|
|
428
|
-
|
|
429
|
-
if (tool === 'eraser') {
|
|
430
|
-
const shapesToErase = shapes.filter(shape => isPointInShape(shape, adjustedPos));
|
|
431
|
-
|
|
432
|
-
if (shapesToErase.length > 0) {
|
|
433
|
-
const newErasedShapes = new Set(erasedShapes);
|
|
434
|
-
shapesToErase.forEach(shape => {
|
|
435
|
-
newErasedShapes.add(shape.id);
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
const newShapes = shapes.filter(shape => !newErasedShapes.has(shape.id));
|
|
439
|
-
setShapes(newShapes);
|
|
440
|
-
setErasedShapes(newErasedShapes);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
else if (tool === 'line') {
|
|
445
|
-
const updatedShape = {
|
|
446
|
-
...currentShape,
|
|
447
|
-
points: [startX, startY, adjustedPos.x, adjustedPos.y]
|
|
448
|
-
};
|
|
449
|
-
setDrawingState(prev => ({ ...prev, currentShape: updatedShape }));
|
|
450
|
-
}
|
|
451
|
-
else if (tool === 'rectangle' || tool === 'ellipse') {
|
|
452
|
-
let width = adjustedPos.x - startX;
|
|
453
|
-
let height = adjustedPos.y - startY;
|
|
454
|
-
|
|
455
|
-
if (shiftPressed) {
|
|
456
|
-
const size = Math.max(Math.abs(width), Math.abs(height));
|
|
457
|
-
width = Math.sign(width) * size;
|
|
458
|
-
height = Math.sign(height) * size;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
let normalizedX = startX;
|
|
462
|
-
let normalizedY = startY;
|
|
463
|
-
let normalizedWidth = width;
|
|
464
|
-
let normalizedHeight = height;
|
|
465
|
-
|
|
466
|
-
if (width < 0) {
|
|
467
|
-
normalizedX = startX + width;
|
|
468
|
-
normalizedWidth = Math.abs(width);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
if (height < 0) {
|
|
472
|
-
normalizedY = startY + height;
|
|
473
|
-
normalizedHeight = Math.abs(height);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
let updatedShape = {
|
|
477
|
-
...currentShape,
|
|
478
|
-
x: normalizedX,
|
|
479
|
-
y: normalizedY,
|
|
480
|
-
width: normalizedWidth,
|
|
481
|
-
height: normalizedHeight
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
setDrawingState(prev => ({ ...prev, currentShape: updatedShape }));
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
else if (transformState.isTransforming && transformState.shapeId) {
|
|
488
|
-
const { startWidth, startHeight, startX, startY, startMouseX, startMouseY, anchor, originalPoints, originalBbox, startFontSize } = transformState;
|
|
489
|
-
|
|
490
|
-
if (!anchor) return;
|
|
491
|
-
|
|
492
|
-
const deltaX = adjustedPos.x - startMouseX;
|
|
493
|
-
const deltaY = adjustedPos.y - startMouseY;
|
|
494
|
-
|
|
495
|
-
let newWidth = startWidth;
|
|
496
|
-
let newHeight = startHeight;
|
|
497
|
-
let newX = startX;
|
|
498
|
-
let newY = startY;
|
|
499
|
-
|
|
500
|
-
switch (anchor) {
|
|
501
|
-
case 'top-left':
|
|
502
|
-
newWidth = startWidth - deltaX;
|
|
503
|
-
newHeight = startHeight - deltaY;
|
|
504
|
-
newX = startX + deltaX;
|
|
505
|
-
newY = startY + deltaY;
|
|
506
|
-
break;
|
|
507
|
-
case 'top-right':
|
|
508
|
-
newWidth = startWidth + deltaX;
|
|
509
|
-
newHeight = startHeight - deltaY;
|
|
510
|
-
newY = startY + deltaY;
|
|
511
|
-
break;
|
|
512
|
-
case 'bottom-left':
|
|
513
|
-
newWidth = startWidth - deltaX;
|
|
514
|
-
newHeight = startHeight + deltaY;
|
|
515
|
-
newX = startX + deltaX;
|
|
516
|
-
break;
|
|
517
|
-
case 'bottom-right':
|
|
518
|
-
newWidth = startWidth + deltaX;
|
|
519
|
-
newHeight = startHeight + deltaY;
|
|
520
|
-
break;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
let finalX = newX;
|
|
524
|
-
let finalY = newY;
|
|
525
|
-
let finalW = newWidth;
|
|
526
|
-
let finalH = newHeight;
|
|
527
|
-
|
|
528
|
-
if (finalW < 0) {
|
|
529
|
-
finalX = finalX + finalW;
|
|
530
|
-
finalW = Math.abs(finalW);
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
if (finalH < 0) {
|
|
534
|
-
finalY = finalY + finalH;
|
|
535
|
-
finalH = Math.abs(finalH);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
if (shiftPressed) {
|
|
539
|
-
const size = Math.max(Math.abs(finalW), Math.abs(finalH));
|
|
540
|
-
finalW = Math.sign(finalW) * size;
|
|
541
|
-
finalH = Math.sign(finalH) * size;
|
|
542
|
-
|
|
543
|
-
switch (anchor) {
|
|
544
|
-
case 'top-left':
|
|
545
|
-
finalX = newX + (newWidth - finalW);
|
|
546
|
-
finalY = newY + (newHeight - finalH);
|
|
547
|
-
break;
|
|
548
|
-
case 'top-right':
|
|
549
|
-
finalY = newY + (newHeight - finalH);
|
|
550
|
-
break;
|
|
551
|
-
case 'bottom-left':
|
|
552
|
-
finalX = newX + (newWidth - finalW);
|
|
553
|
-
break;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
const constrained = constrainToCanvas(finalX, finalY, finalW, finalH);
|
|
558
|
-
finalX = constrained.x;
|
|
559
|
-
finalY = constrained.y;
|
|
560
|
-
finalW = constrained.width;
|
|
561
|
-
finalH = constrained.height;
|
|
562
|
-
|
|
563
|
-
const updatedShapes = shapes.map(s => {
|
|
564
|
-
if (s.id === transformState.shapeId) {
|
|
565
|
-
|
|
566
|
-
if ((s.type === 'path' || s.type === 'line' || s.type === 'highlighter') &&
|
|
567
|
-
originalPoints && originalBbox)
|
|
568
|
-
{
|
|
569
|
-
const newBbox = {
|
|
570
|
-
x: finalX,
|
|
571
|
-
y: finalY,
|
|
572
|
-
width: finalW,
|
|
573
|
-
height: finalH
|
|
574
|
-
};
|
|
575
|
-
const transformedPoints = transformPoints(originalPoints, originalBbox, newBbox);
|
|
576
|
-
|
|
577
|
-
return {
|
|
578
|
-
...s,
|
|
579
|
-
width: finalW,
|
|
580
|
-
height: finalH,
|
|
581
|
-
x: finalX,
|
|
582
|
-
y: finalY,
|
|
583
|
-
points: transformedPoints
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
else {
|
|
587
|
-
return {
|
|
588
|
-
...s,
|
|
589
|
-
width: finalW,
|
|
590
|
-
height: finalH,
|
|
591
|
-
x: finalX,
|
|
592
|
-
y: finalY
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
return s;
|
|
597
|
-
});
|
|
598
|
-
|
|
599
|
-
setShapes(updatedShapes);
|
|
600
|
-
}
|
|
601
|
-
else if (isDragging && selectedId) {
|
|
602
|
-
const shape = shapes.find(s => s.id === selectedId);
|
|
603
|
-
|
|
604
|
-
const deltaX = adjustedPos.x - dragStart.x;
|
|
605
|
-
const deltaY = adjustedPos.y - dragStart.y;
|
|
606
|
-
|
|
607
|
-
const updatedShapes = shapes.map(s => {
|
|
608
|
-
if (s.id === selectedId) {
|
|
609
|
-
const newX = selectedShapeStart.x + deltaX;
|
|
610
|
-
const newY = selectedShapeStart.y + deltaY;
|
|
611
|
-
|
|
612
|
-
const constrained = constrainToCanvas(newX, newY, s.width, s.height);
|
|
613
|
-
|
|
614
|
-
if ((s.type === 'path' || s.type === 'line' || s.type === 'highlighter') && s.points && originalPointsOnDragStart.length > 0) {
|
|
615
|
-
const deltaFromOriginal = {
|
|
616
|
-
x: constrained.x - selectedShapeStart.x,
|
|
617
|
-
y: constrained.y - selectedShapeStart.y
|
|
618
|
-
};
|
|
619
|
-
|
|
620
|
-
const newPoints = originalPointsOnDragStart.map((point, index) =>
|
|
621
|
-
index % 2 === 0 ? point + deltaFromOriginal.x : point + deltaFromOriginal.y
|
|
622
|
-
);
|
|
623
|
-
|
|
624
|
-
return {
|
|
625
|
-
...s,
|
|
626
|
-
x: constrained.x,
|
|
627
|
-
y: constrained.y,
|
|
628
|
-
points: newPoints
|
|
629
|
-
};
|
|
630
|
-
} else {
|
|
631
|
-
return {
|
|
632
|
-
...s,
|
|
633
|
-
x: constrained.x,
|
|
634
|
-
y: constrained.y
|
|
635
|
-
};
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
return s;
|
|
639
|
-
});
|
|
640
|
-
|
|
641
|
-
setShapes(updatedShapes);
|
|
642
|
-
}
|
|
643
|
-
}, [
|
|
644
|
-
shapes, setShapes, tool, isDragging, selectedId,
|
|
645
|
-
dragStart, selectedShapeStart, originalPointsOnDragStart,
|
|
646
|
-
erasedShapes, setErasedShapes, setDrawingState, scale, constrainToCanvas
|
|
647
|
-
]);
|
|
648
|
-
|
|
649
|
-
const handleMouseUp = useCallback(() => {
|
|
650
|
-
if (isDragging) {
|
|
651
|
-
setIsDragging(false);
|
|
652
|
-
setOriginalPointsOnDragStart([]);
|
|
653
|
-
saveToHistory(shapes);
|
|
654
|
-
}
|
|
655
|
-
}, [isDragging, shapes, saveToHistory]);
|
|
656
|
-
|
|
657
|
-
return {
|
|
658
|
-
isDragging,
|
|
659
|
-
setIsDragging,
|
|
660
|
-
dragStart,
|
|
661
|
-
setDragStart,
|
|
662
|
-
selectedShapeStart,
|
|
663
|
-
setSelectedShapeStart,
|
|
664
|
-
originalPointsOnDragStart,
|
|
665
|
-
setOriginalPointsOnDragStart,
|
|
666
|
-
erasedShapes,
|
|
667
|
-
setErasedShapes,
|
|
668
|
-
eraserHistoryStart,
|
|
669
|
-
setEraserHistoryStart,
|
|
670
|
-
constrainToCanvas,
|
|
671
|
-
handleMouseDown,
|
|
672
|
-
handleMouseMove,
|
|
673
|
-
handleMouseUp
|
|
674
|
-
};
|
|
675
|
-
};
|