752 Commits

Author SHA1 Message Date
David Luzar
c1c37a6ee7
fix: align library item previews to center (#4447) 2021-12-21 19:59:36 +01:00
Aakansha Doshi
089b05db1b
fix: switch cursor to center of container when adding text when dimensions are too small (#4452) 2021-12-21 19:00:01 +05:30
Aakansha Doshi
c2a8712593
fix: update viewport coords correctly when editing text (#4416) 2021-12-17 11:38:18 +01:00
Aakansha Doshi
98b5c37e45
feat: bind text to shapes when pressing enter and support sticky notes 🎉 (#4343)
* feat: Word wrap inside rect and increase height when size exceeded

* fixes for auto increase in height

* fix height

* respect newlines when wrapping text

* shift text area when height increases beyond mid rect height until it reaches to the top

* select bound text if present when rect selected

* mutate y coord after text submit

* Add padding of 30px and update dimensions acordingly

* Don't allow selecting bound text element directly

* support deletion of bound text element when rect deleted

* trim text

* Support autoshrink and improve algo

* calculate approx line height instead of hardcoding

* use textContainerId instead of storing textContainer element itself

* rename boundTextElement -> boundTextElementId

* fix text properties not getting reflected after edit inside rect

* Support resizing

* remove ts ignore

* increase height of container when text height increases while resizing

* use original text when editing/resizing so it adjusts based on original text

* fix tests

* add util isRectangleElement

* use isTextElement util everywhere

* disable selecting text inside rect when selectAll

* Bind text to circle and diamond as well

* fix tests

* vertically center align the text always

* better vertical align

* Disable binding arrows for text inside shapes

* set min width for text container when text is binded to container

* update dimensions of container if its less than min width/ min height

* Allow selecting of text container for transparent containers when clicked inside

* fix test

* preserve whitespaces between long word exceeding width and next word
Use word break instead of whitespace no wrap for better readability and support safari

* Perf improvements for measuring text width and resizing
* Use canvas measureText instead of our algo. This has reduced the perf ~ 10 times
* Rewrite wrapText algo to break in words appropriately and for longer words
calculate the char width in order unless max width reached. This makes the
the number of runs linear (max text length times) which was earlier
textLength * textLength-1/2 as I was slicing the chars from end until max width reached for each run
* Add a util to calculate getApproxCharsToFitInWidth to calculate min chars to fit in a line

* use console.info so eslint doesnt warn :p

* cache char width and don't call resize unless min width exceeded

* update line height and height correctly when text properties inside container updated

* improve vertical centering when text properties updated, not yet perfect though

* when double clicked inside a conatiner  take the cursor to end of text same as what happens when enter is pressed

* Add hint when container selected

* Select container when escape key is pressed after submitting text

* fix copy/paste when using copy/paste action

* fix copy when dragged with alt pressed

* fix export to svg/png

* fix add to library

* Fix copy as png/svg

* Don't allow selecting text when using selection tool and support resizing when multiple elements include ones with binded text selectec

* fix rotation jump

* moove all text utils to textElement.ts

* resize text element only after container resized so that width doesnt change when editing

* insert the remaining chars for long words once it goes beyond line

* fix typo, use string for character type

* renaming

* fix bugs in word wrap algo

* make grouping work

* set boundTextElementId only when text present else unset it

* rename textContainerId to containerId

* fix

* fix snap

* use originalText in redrawTextBoundingBox so height is calculated properly and center align works after props updated

* use boundElementIds and also support binding text in images 🎉

* fix the sw/se ends when resizing from ne/nw

* fix y coord when resizing from north

* bind when enter is pressed, double click/text tool willl edit the binded text if present else create a new text

* bind when clicked on center of container

* use pre-wrap instead of normal so it works in ff

* use container boundTextElement when container present and trying to edit text

* review fixes

* make getBoundTextElementId type safe and check for existence when using this function

* fix

* don't duplicate boundElementIds when text submitted

* only remove last trailing space if present which we have added when joining words

* set width correctly when resizing to fix alignment issues

* make duplication work using cmd/ctrl+d

* set X coord correctly during resize

* don't allow resize to negative dimensions when text is bounded to container

* fix, check last char is space

* remove logs

* make sure text editor doesn't go beyond viewport and set container dimensions in case it overflows

* add a util isTextBindableContainer to check if the container could bind text
2021-12-16 21:14:03 +05:30
David Luzar
7db63bd397
feat: redesign toolbar & tweaks (#4387) 2021-12-15 15:31:44 +01:00
David Luzar
104664cb9e
feat: support selecting multiple points when editing line (#4373) 2021-12-13 13:35:07 +01:00
dwelle
9b8ee3cacf feat: horizontally center toolbar menu 2021-12-05 17:47:19 +01:00
David Luzar
06db702b5d
feat: support selecting multiple library items via shift (#4306) 2021-11-26 12:46:23 +01:00
David Luzar
b53d1f6f3e
feat: improve library preview image generation on publish (#4321)
Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
2021-11-26 11:46:13 +01:00
David Luzar
8ff159e76e
fix: export scale quality regression (#4316) 2021-11-25 14:05:22 +01:00
David Luzar
6dd0e6a4c5
fix: remove 100% height from tooltip container to fix layout issues (#3980) 2021-11-24 17:16:18 +01:00
David Luzar
cc4b0c2932
feat: supply version param when installing libraries (#4305) 2021-11-23 17:59:26 +01:00
David Luzar
59e9651547
feat: log FS abortError to console (#4279) 2021-11-19 10:54:23 +01:00
Aakansha Doshi
e4d02fb275
feat: Add validation for website and remove validation for library item name (#4269)
* Github->GitHub

* allow numbers

* remove validation for lib/item name
2021-11-18 10:24:26 +00:00
David Luzar
e60e48e67d
fix: account for libraries v2 when prompting (#4263) 2021-11-17 19:54:40 +00:00
Aakansha Doshi
84d1d9993c
feat: Allow publishing libraries from UI (#4115)
* feat: Allow publishing libraries from UI

* Add status for each library item and show publish only for unpublished libs

* Add publish library dialog

* Pass the data to publish the library

* pass lib blob

* Handle old and new libraries when importing

* Better error handling

* Show publish success when library submitted for review

* don't close library when publish success dialog open

* Support multiple libs deletion and publish

* Set status to published once library submitted for review

* Save  to LS after library published

* unique key for publish and delete

* fix layout shift when hover and also highlight selected library items

* design improvements

* migrate old library to the new one

* fix

* fix tests

* use i18n

* Support submit type in toolbutton

* Use html5 form validation, add asteriks for required fields, add twitter handle, mark github handle optional

* Add twitter handle in form state

* revert html5 validation as fetch is giving some issues :/

* clarify types around LibraryItems

* Add website optional field

* event.preventDefault to make htm5 form validationw work

* improve png generation by drawing a bounding box rect and aligining pngs to support multiple libs png

* remove ts-ignore

* add placeholders for fields

* decrease clickable area for checkbox by 0.5em

* add checkbox background color

* rename `items` to `elements`

* improve checkbox hit area

* show selected library items in publish dialog

* decrease dimensions by 3px to improve jerky experience when opening/closing library menu

* Don't close publish dialog when clicked outside

* Show selected library actions only when any library item selected and use icons instead of button

* rename library to libraryItems in excalidrawLib and added migration

* change icon and swap bg/color

* use blue brand color for hover/selected states

* prompt for confirmation when deleting library items

* separate unpublished items from published

* factor `LibraryMenu` into own file

* i18n and minor fixes for unpublished items

* fix not rendering empty cells when library empty

* don't render published section if empty and unpublished is not

* Add edit name functionality for library items

* fix

* edit lib name with onchange/blur

* bump library version

* prefer response error message

* add library urls to ENV vars

* mark lib item name as required

* Use input only for lib item name

* better error validation for lib items

* fix label styling for lib items

* design and i18n fixes

* Save publish dialog data to local storage and clear once published

* Add a note about MIT License

* Add note for guidelines

* Add tooltip for publish button

* Show spinner in submit button when submission is in progress

* assign id for older lib items when installed and set status as published for all lib when installed

* update export icon and support export library for selected items

* move LibraryMenuItems into its own component as its best to keep one comp per file

* fix spec

* Refactoring the library actions for reusablility

* show only load when items not present

* close on click outside in publish dialog

* ad dialog description and tweak copy

* vertically center input labels

* align input styles

* move author name input to other usernames

* rename param

* inline to simplify

* fix to not inline `undefined` class names

* fix version & include only latest lib schema in library export type

* await response callback

* refactor types

* refactor

* i18n

* align casing & tweaks

* move ls logic to publishLibrary

* support removal of item inside publish dialog

* fix labels for trash icon when items selected

* replace window.confirm for removal libs with confirm dialog

* fix input/textarea styling

* move library item menu scss to its own file

* use blue for load and cyan for publish

* reduce margin for submit and make submit => Submit

* Make library items header sticky

* move publish icon to left so there is no jerkiness when unpublish items selected

* update url

* fix grid gap between lib items

* Mark older items imported from initial data as unpublished

* add text to publish button on non-mobile

* add items counter

* fix test

* show personal and excal libs sections and personal goes first

* show toast on adding to library via contextMenu

* Animate plus icon and not the pending item

* fix snap

* use i18n when no item in publish dialog

* tweak style of new lib item

* show empty cells for both sections and set status as published for installed libs

* fix

* push selected item first in unpublished section

* set status as published for imported from webiste but unpublished for json

* Add items to the begining of library

* add `created` library item attr

* fix test

* use `defaultValue` instead of `value`

* fix dark theme styles

* fix toggle button not closing library

* close library menu on Escape

* tweak publish dialog item remove style

* fix remove icon in publish dialog

Co-authored-by: dwelle <luzar.david@gmail.com>
2021-11-17 23:53:43 +05:30
Aakansha Doshi
3ff9744b39
feat: create confirm dialog to use instead of window.confirm (#4256)
* feat: create confirm dialog to use instead of window.confirm

* move confirm to right

* add types

* less margin
2021-11-16 18:55:56 +05:30
Lipis
2b29b9a96d
chore: Consistent case for clear canvas, change font of buttons and clean up unused strings (#4195)
* chore: Consistent case for clear canvas and font

* Remove unused

* remove
2021-11-03 21:31:27 +02:00
Lipis
8d4f455cd3
chore: Update Typescript to 4.4.4 (#4188) 2021-11-02 14:24:16 +02:00
Lipis
1c7056bdaa
chore: bump Prettier to the latest (#4185) 2021-11-01 15:24:05 +02:00
David Luzar
3369035f40
feat: add hint around canvas panning (#4159) 2021-11-01 13:36:06 +01:00
David Luzar
790e6da500
fix: images not initialized correctly (#4157)
* fix: image not initialized correctly due to not renewing `state.pendingImageElement`

* ensure we replace elements on update

* set file as errored on >= 400 status respones
2021-11-01 10:44:57 +01:00
David Luzar
c61f95a327
fix: image-related fixes (#4147)
* flush queues on portal close

* fix mouse broadcast race condition

* stop mutating image elements when updating status

to fix race condition when closing/opening collab room

* check `files` when resolving `LayerUI`

* fix displaying AbortError
2021-10-30 23:40:35 +02:00
Jonas Bleyl
8d8769ba4e
feat: add triangle arrowhead (#4024)
Co-authored-by: ad1992 <aakansha1216@gmail.com>
Co-authored-by: dwelle <luzar.david@gmail.com>
2021-10-27 19:27:39 +02:00
David Luzar
5c5b8c517f
fix: clear image/shape cache of affected elements when adding files (#4089) 2021-10-23 14:17:04 +02:00
David Luzar
7dbd0c5e0a
fix: clear LibraryUnit DOM on unmount (#4084) 2021-10-22 22:07:20 +02:00
David Luzar
ba35eb8f8c
fix: pasting images on firefox (#4085) 2021-10-22 21:04:04 +02:00
David Luzar
163ad1f4c4
feat: image support (#4011)
Co-authored-by: Emil Atanasov <heitara@gmail.com>
Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
2021-10-21 22:05:48 +02:00
Aakansha Doshi
0f0244224d
feat: Use dialog component for clear canvas instead of window confirm (#4075)
* feat: Use dialog component for clear canvas instead of window confirm

* reduce font weight

* fix specs

* update button name and use action

* export clearCanvas from actions
2021-10-21 17:35:28 +05:30
Aakansha Doshi
c6ffc06541
feat: support renderTopRightUI in mobile (#4065) 2021-10-17 21:44:46 +05:30
Aakansha Doshi
ff29780760
Refactor: convert initializeApp to func component and use JSX transform in the codebase (#4056) 2021-10-14 22:56:51 +05:30
Aakansha Doshi
463857ad9a
feat: Export THEME from the package (#4055)
* Use Theme type everywhere
* Rename Appearance type to Theme for consistency
* Reorder headers in readme
The host don't need to pass hardcoded strings any more and instead can use the exported constant
2021-10-14 14:15:57 +05:30
Steve Ruiz
00c6940851
fix: freehand points (#4031)
Co-authored-by: dwelle <luzar.david@gmail.com>
2021-10-11 20:11:26 +02:00
David Luzar
54739cd2df
fix: abstract and fix legacy fs (#4032) 2021-10-07 13:19:40 +02:00
Shubham Shah
75aeaa6c38
fix: context menu positioning (#4025) 2021-10-04 12:13:17 +02:00
zsviczian
7d1fddc144
fix: onPaste should return false to prevent paste action (#3974)
* Update App.tsx

* Update README_NEXT.md

* Update CHANGELOG.md

* Update App.tsx

* Update App.tsx

* Update src/packages/excalidraw/CHANGELOG.md

* fix lint

Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
2021-09-13 20:58:53 +05:30
David Luzar
f0f13ed694
fix: permanent zoom mode (#3931) 2021-08-23 22:47:29 +02:00
Thomas Steiner
621812d0eb
feat: Make color ARIA labels better (#3871)
* Make color aria labels better

* Use isTransparent helper

* Fix import

* Try to fix test

* More test fixes

* Reuse variable
2021-08-02 20:18:55 +02:00
David Luzar
b2c4552416
feat: re-order zoom buttons (#3837)
* feat: re-order zoom buttons

* undo last commit & change zoomOut/zoomIn order
2021-07-16 23:47:43 +02:00
David Luzar
99623334d1
feat: add undo/redo buttons & tweak footer (#3832)
Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
2021-07-15 18:48:03 +02:00
David Laban
685abac81a
feat: resave to png/svg with metadata if you loaded your scene from a png/svg file (#3645)
Co-authored-by: dwelle <luzar.david@gmail.com>
2021-07-15 15:54:26 +02:00
David Luzar
0749d2c1f3
fix: color picker shortcuts not working when elements selected (#3817) 2021-07-10 21:05:00 +00:00
connorhanafee
5fabc57277
fix: view mode cursor adjustments (#3809) 2021-07-10 00:00:13 +02:00
David Luzar
55d3287abf
fix: include deleted elements when passing to restore (#3802) 2021-07-05 13:43:53 +02:00
Aakansha Doshi
e3e967421e
fix: import React before using jsx (#3804) 2021-07-05 15:59:09 +05:30
Jakub Koralewski
ee64a7e264
fix: ensure s and g shortcuts work on no selection (#3800)
Co-authored-by: dwelle <luzar.david@gmail.com>
2021-07-04 22:27:33 +02:00
David Luzar
097362662d
feat: pass localElements to restore and restoreElement API's and bump versions of duplicate elements on import (#3797) 2021-07-04 22:23:35 +02:00
Aakansha Doshi
f861a9fdd0
feat: support appState.exportEmbedScene to embed scene data in exportToSvg util (#3777)
* feat: add embedScene attribute to exportToSvg util

* fix

* return promise

* add docs and remove

* fix

* fix tests

* use

* fix

* fix

* remove metadata and use exportEmbedScene

* fix

* fix

* fix

* fix

* IIFE
2021-07-03 02:07:01 +05:30
connorhanafee
44402f42bf
feat: switch to selection tool on library item insert (#3773)
* switch to selection tool on library item insert

* add test

Co-authored-by: dwelle <luzar.david@gmail.com>
2021-06-28 12:00:33 +02:00
connorhanafee
969d3c694a
fix: keep binding for attached arrows after changing text (#3754)
Co-authored-by: David Luzar <luzar.david@gmail.com>
2021-06-21 14:31:49 +02:00