33 Commits

Author SHA1 Message Date
David Luzar
b1b325b9a7
feat: add "unlock all elements" to canvas contextMenu () 2023-05-13 22:52:03 +02:00
David Luzar
f640ddc2aa
fix: incorrectly duplicating items on paste/library insert (
* fix: incorrectly duplicating items on paste/library insert

* fix: deduplicate element ids on restore

* tests
2023-04-16 17:22:16 +02:00
Aakansha Doshi
83383977f5
feat: add line height attribute to text element ()
* feat: add line height attribute to text element

* lint

* update line height when redrawing text bounding box

* fix tests

* retain line height when pasting styles

* fix test

* create a util for calculating ling height using old algo

* update line height when resizing multiple text elements

* make line height backward compatible

* udpate line height for older element when font size updated

* remove logs

* Add specs

* lint

* review fixes

* simplify by changing `lineHeight` from px to unitless

* make param non-optional

* update comment

* fix: jumping text due to font size being calculated incorrectly

* update line height when font family is updated

* lint

* Add spec

* more specs

* rename to getDefaultLineHeight

* fix getting lineHeight for potentially undefined fontFamily

* reduce duplication

* fix fallback

* refactor and comment tweaks

* fix

---------

Co-authored-by: dwelle <luzar.david@gmail.com>
2023-03-22 11:32:38 +05:30
Samyat Gautam
0726911fa6
fix: containerizing text incorrectly updates arrow bindings ()
Co-authored-by: dwelle <luzar.david@gmail.com>
2023-03-18 15:00:28 +00:00
David Luzar
8542c95a7a
fix: move utility types out of .d.ts file to fix exported declaration files () 2023-03-04 19:21:57 +01:00
Ryan Di
5854ac3eed
feat: better default radius sizes for rectangles ()
Co-authored-by: Ryan <diweihao@bytedance.com>
Co-authored-by: dwelle <luzar.david@gmail.com>
2022-12-08 16:48:49 +01:00
Aakansha Doshi
760fd7b3a6
feat: Support labels for arrow 🔥 ()
* feat: support arrow with text

* render arrow -> clear rect-> render text

* move bound text when linear elements move

* fix centering cursor when linear element rotated

* fix y coord when new line added and container has 3 points

* update text position when 2nd point moved

* support adding label on top of 2nd point when 3 points are present

* change linear element editor shortcut to cmd+enter and fix tests

* scale bound text points when resizing via bounding box

* ohh yeah rotation works :)

* fix coords when updating text properties

* calculate new position after rotation always from original position

* rotate the bound text by same angle as parent

* don't rotate text and make sure dimensions and coords are always calculated from original point

* hardcoding the text width for now

* Move the linear element when bound text hit

* Rotation working yaay

* consider text element angle when editing

* refactor

* update x2 coords if needed when text updated

* simplify

* consider bound text to be part of bounding box when hit

* show bounding box correctly when multiple element selected

* fix typo

* support rotating multiple elements

* support multiple element resizing

* shift bound text to mid point when odd points

* Always render linear element handles inside editor after element rendered so point is visible for bound text

* Delete bound text when point attached to it deleted

* move bound to mid segement mid point when points are even

* shift bound text when points nearby deleted and handle segment deletion

* Resize working :)

* more resize fixes

* don't update cache-its breaking delete points, look for better soln

* update mid point cache for bound elements when updated

* introduce wrapping when resizing

* wrap when resize for 2 pointer linear elements

* support adding text for linear elements with more than 3 points

* export to svg  working :)

* clip from nearest enclosing element with non transparent color if present when exporting and fill with correct color in canvas

* fix snap

* use visible elements

* Make export to svg work with Mask :)

* remove id

* mask canvas linear element area where label is added

* decide the position of bound text during render

* fix coords when editing

* fix multiple resize

* update cache when bound text version changes

* fix masking when rotated

* render text in correct position in preview

* remove unnecessary code

* fix masking when rotating linear element

* fix masking with zoom

* fix mask in preview for export

* fix offsets in export view

* fix coords on svg export

* fix mask when element rotated in svg

* enable double-click to enter text

* fix hint

* Position cursor correctly and text dimensiosn when height of element is negative

* don't allow 2 pointer linear element with bound text width to go beyond min width

* code cleanup

* fix freedraw

* Add padding

* don't show vertical align action for linear element containers

* Add specs for getBoundTextElementPosition

* more specs

* move some utils to linearElementEditor.ts

* remove only :p

* check absoulte coods in test

* Add test to hide vertical align for linear eleemnt with bound text

* improve export preview

* support labels only for arrows

* spec

* fix large texts

* fix tests

* fix zooming

* enter line editor with cmd+double click

* Allow points to move beyond min width/height for 2 pointer arrow with bound text

* fix hint for line editing

* attempt to fix arrow getting deselected

* fix hint and shortcut

* Add padding of 5px when creating bound text and add spec

* Wrap bound text when arrow binding containers moved

* Add spec

* remove

* set boundTextElementVersion to null if not present

* dont use cache when version mismatch

* Add a padding of 5px vertically when creating text

* Add box sizing content box

* Set bound elements when text element created to fix the padding

* fix zooming in editor

* fix zoom in export

* remove globalCompositeOperation and use clearRect instead of fillRect
2022-12-05 21:03:13 +05:30
Jakob Guddas
79bd3b8cda
fix: replaced KeyboardEvent.code with KeyboardEvent.key for all letters ()
* fix: Replaced KeyboardEvent.code with KeyboardEvent.key for all letters

* fix: reverted all keybindings that included alt to use code instead of keys

Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
2022-10-21 00:31:26 +05:30
Ryan Di
3a776f8795
fix: image-mirroring in export preview and in exported svg ()
Co-authored-by: dwelle <luzar.david@gmail.com>
2022-09-17 21:02:13 +00:00
David Luzar
d2cc76e52e
feat: support adding multiple library items on canvas () 2022-05-11 15:51:02 +02:00
Tom Sherman
327ed0e2d1
feat: Element locking ()
Co-authored-by: dwelle <luzar.david@gmail.com>
Co-authored-by: Zsolt Viczian <viczian.zsolt@gmail.com>
2022-04-07 13:43:29 +02:00
Tom Milligan
4d5f00ff08
fix: don't crash on drop highlighted text onto canvas () 2022-03-09 11:51:13 +01:00
David Luzar
20de06ef50
fix: paste styles shortcut ()
Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
2022-03-09 10:59:44 +01:00
David Luzar
6d0716eb6b
fix: binding text to non-bindable containers and not always preferring selection () 2022-03-02 17:04:09 +01:00
David Luzar
79d323fab1
refactor: simplify zoom by removing zoom.translation () 2022-01-29 21:12:44 +01:00
Aakansha Doshi
8b2b03347c
fix: bound text not atomic with container when changing z-index ()
Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
Co-authored-by: dwelle <luzar.david@gmail.com>
2021-12-17 13:10:37 +00:00
Lipis
8d4f455cd3
chore: Update Typescript to 4.4.4 () 2021-11-02 14:24:16 +02:00
Lipis
1c7056bdaa
chore: bump Prettier to the latest () 2021-11-01 15:24:05 +02:00
connorhanafee
969d3c694a
fix: keep binding for attached arrows after changing text ()
Co-authored-by: David Luzar <luzar.david@gmail.com>
2021-06-21 14:31:49 +02:00
David Luzar
c819b653bf
fix: on contextMenu, use selected element regardless of z-index () 2021-05-29 22:33:53 +02:00
David Luzar
6d40039f08
feat: allow inner-drag-selecting with cmd/ctrl ()
* feat: allow inner-drag-selecting with cmd/ctrl

* don't use  cursor when pressing cmd/ctrl

* ensure we reset deselected groups

* add tests

* add docs

* couple fixes around group selection
2021-05-20 22:28:34 +02:00
Steve Ruiz
49c6bdd520
feat: improved freedraw ()
Co-authored-by: dwelle <luzar.david@gmail.com>
2021-05-09 17:42:10 +02:00
Riley Schnee
b0d7ff290f
feat: Add option to flip single element on the context menu ()
Co-authored-by: dwelle <luzar.david@gmail.com>
2021-03-26 16:45:08 +01:00
Luo
bc414ccaaf
feat: tweak editing behavior ()
* feat: tweak editing behavior

* fix tests

Co-authored-by: dwelle <luzar.david@gmail.com>
2020-12-25 19:34:47 +01:00
Steve Ruiz
c291edfc44
Add Arrowheads to Arrows ()
Co-authored-by: dwelle <luzar.david@gmail.com>
Co-authored-by: Lipis <lipiridis@gmail.com>
2020-12-08 16:02:55 +01:00
João Forja
aa221837fc
Enhance aspect ratio tools | Rectangle, Diamond, Ellipses ()
Co-authored-by: dwelle <luzar.david@gmail.com>
2020-12-07 00:39:31 +02:00
Lipis
014097a97e
refactor: Stop using the deprecated keyCode ()
Co-authored-by: Lipis <lipiridis@gmail.com>
Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-12-01 22:36:06 +01:00
David Luzar
ba3f548b91
Fix library dnd () 2020-10-30 21:01:41 +01:00
David Luzar
b3263c2a69
fix encoding of embed data & compress () 2020-10-15 21:31:21 +02:00
David Luzar
7618ca48d7
retain local appState props on restore ()
Co-authored-by: Lipis <lipiridis@gmail.com>
2020-10-13 13:46:52 +02:00
David Luzar
aaddde5dd9
Fix history initialization () 2020-09-09 21:08:06 +02:00
David Luzar
26ef235019
rebind arrow on rotation () 2020-08-29 14:16:40 +02:00
David Luzar
8b9e2a540d
factor out test helpers () 2020-08-28 10:15:29 +02:00