294 Commits

Author SHA1 Message Date
Gasim Gasimzada
1e4ce77612
Reintroduce multi-point arrows and add migration for it ()
* Revert "Revert "Feature: Multi Point Arrows ()" ()"

This reverts commit 3d2e59bfed4fa41a0cae49ee567a6f95ca26e7bf.

* Convert old arrow spec to new one

* Remove unnecessary failchecks and fix context transform issue in retina displays

* Remove old points failcheck from getArrowAbsoluteBounds

* Remove all failchecks for old arrow

* remove the rest of unnecessary checks

* Set default values for the arrow during import

* Add translations

* fix restore using unmigrated elements for state computation

* don't use width/height when migrating from new arrow spec

Co-authored-by: David Luzar <luzar.david@gmail.com>
Co-authored-by: Christopher Chedeau <vjeuxx@gmail.com>
2020-02-01 15:49:18 +04:00
Christopher Chedeau
4ff88ae03d
Fix caret for real! ()
Turns out the root cause was the outline. For some reason, doing "transparent" doesn't work but doing "1px solid transparent" does. Don't know why but I'll take it!
2020-02-01 06:07:08 +00:00
Christopher Chedeau
9a76556bea
Fixed wysiwyg carret disappearing on Chrome ()
There's a bug where the carret doesn't show up when the text is first focused on Chrome with the previous combination of CSS. I tweaked it and now it seems to work (don't ask me why!).

Unfortunately on Safari, ever since we moved to contentEditable on , the carret disappeared the first time. I unsuccessfully tried to repro in a smaller codebase ( https://jsfiddle.net/u2mjs90y/1/ ) but it does work in Safari...

I'm not exactly sure what's going on, there are bunch of issues opened against this bug when googling against all the browsers...
2020-02-01 05:54:33 +00:00
Christopher Chedeau
70db792549
Allow copy pasting inside of wysiwyg element ()
We did some hackery to prevent copy pasting when we didn't support multilines. But we do now so we can remove it.

Interestingly, newlines are actually <br /> elements. So we need to tweak the isInputLike logic a bit
2020-02-01 04:06:27 +00:00
Christopher Chedeau
e50dc5dbed
Fix wysiwyg text overflow ()
By using position: fixed like the rest of the UI components, it will no longer make the body change size and have bad side effects like scrolling.

Fixes 
2020-02-01 04:05:53 +00:00
David Luzar
3d2e59bfed
Revert "Feature: Multi Point Arrows ()" ()
This reverts commit 16263e942b7b690bb3e97340383009016129d489.
2020-01-31 18:56:55 +01:00
Gasim Gasimzada
16263e942b
Feature: Multi Point Arrows ()
* Add points to arrow on double click

* Use line generator instead of path to generate line segments

* Switch color of the circle when it is on an existing point in the segment

* Check point against both ends of the line segment to find collinearity

* Keep drawing the arrow based on mouse position until shape is changed

* Always select the arrow when in multi element mode

* Use curves instead of lines when drawing arrow points

* Add basic collision detection with some debug points

* Use roughjs shape when performing hit testing

* Draw proper handler rectangles for arrows

* Add argument to renderScene in export

* Globally resize all points on the arrow when bounds are resized

* Hide handler rectangles if an arrow has no size

- Allow continuing adding arrows when selected element is deleted

* Add dragging functionality to arrows

* Add SHIFT functionality to two point arrows

- Fix arrow positions when scrolling
- Revert the element back to selection when not in multi select mode

* Clean app state for export (JSON)

* Set curve options manually instead of using global options

- For some reason, this fixed the flickering issue in all shapes when arrows are rendered

* Set proper options for the arrow

* Increaase accuracy of hit testing arrows

- Additionally, skip testing if point is outside the domain of arrow and each curve

* Calculate bounding box of arrow based on roughjs curves

- Remove domain check per curve

* Change bounding box threshold to 10 and remove unnecessary code

* Fix handler rectangles for 2 and multi point arrows

- Fix margins of handler rectangles when using arrows
- Show handler rectangles in endpoints of 2-point arrows

* Remove unnecessary values from app state for export

* Use `resetTransform` instead of "retranslating" canvas space after each element rendering

* Allow resizing 2-point arrows

- Fix position of one of the handler rectangles

* refactor variable initialization

* Refactored to extract out mult-point generation to the abstracted function

* prevent dragging on arrow creation if under threshold

* Finalize selection during multi element mode when ENTER or ESC is clicked

* Set dragging element to null when finalizing

* Remove pathSegmentCircle from code

* Check if element is any "non-value" instead of NULL

* Show two points on any two point arrow and fix visibility of arrows during scroll

* Resume recording when done with drawing

- When deleting a multi select element, revert back to selection element type

* Resize arrow starting points perfectly

* Fix direction of arrow resize based for NW

* Resume recording history when there is more than one arrow

* Set dragging element to NULL when element is not locked

* Blur active element when finalizing

* Disable undo/redo for multielement, editingelement, and resizing element

- Allow undoing parts of the arrow

* Disable element visibility for arrow

* Use points array for arrow bounds when bezier curve shape is not available

Co-authored-by: David Luzar <luzar.david@gmail.com>
Co-authored-by: Preet <833927+pshihn@users.noreply.github.com>
2020-01-31 18:16:33 +01:00
David Luzar
7b842fc330 simplify distance helper and factor out common bounds helper ()
* simplify distance helper

* factor out common bounds helper
2020-01-26 19:15:08 +00:00
lissitz
1bae203a78 changing new shape property sets it as default ()
* changing new shape property sets it as default

* set correct opacity while editing new test

Co-authored-by: Christopher Chedeau <vjeuxx@gmail.com>
2020-01-25 09:58:57 -08:00
Loris
413c387c7c Add onCancel callback to textWysiwyg for cleanup () 2020-01-25 09:45:23 -08:00
David Luzar
afb1d6725f
Normalize dimensions ()
* normalize dimensions of non-linear elements

* fix element type check regression
2020-01-24 20:45:52 +01:00
Jilles Soeters
d65e90209c Allow multiline text ()
* Allow multiline text

* Figure out offset correctly

* Run prettier
2020-01-24 20:35:51 +02:00
Lipis
ee68af0fd3
Set Trailing Cmma to () 2020-01-24 12:04:54 +02:00
Günay Mert Karadoğan
926b4f24e6 Draw horizontal/vertical lines/arrows when shift pressed ()
* Draw horizontal/vertical lines/arrows when shift pressed

* Refactor resizing with delta

* Resize arrows/lines perfectly when shift pressed
2020-01-23 10:21:04 +01:00
Dvir Azulay
a856ce06e9 Allow dragging transparent elements when selected ()
* Allow dragging transparent elements when selected

Addresses 

* Update package.json
2020-01-21 21:10:49 -08:00
David Luzar
2340dddaad Sync panel props to editing element ()
* ensure panel props are sync to editing elem

* ensure we don't create empty-text elements (fixes )

* remove dead code

Co-authored-by: Christopher Chedeau <vjeuxx@gmail.com>
2020-01-20 15:16:22 -08:00
Günay Mert Karadoğan
d505c6615d Fix reversed cursor issues on resize with bi-directional cursors () 2020-01-19 23:11:46 +02:00
Faustino Kialungila
86cb228df4 Trim wysiwyg text to avoid misalignment on Firefox () 2020-01-19 20:52:19 +01:00
Sosuke Suzuki
5563dd30d7 Modify to ignore enter-key in IME composing () 2020-01-18 14:13:44 -08:00
Günay Mert Karadoğan
8bc049a0b9 Remove resized element if it is invisibly small () 2020-01-16 23:16:11 +01:00
Bakhtiiar Muzakparov
8db8827c6f feat: add line shape ()
* feat: add line shape

* fix: align line tool

* fix: hitbox bug sw to ne

* fix: add stroke width n sloppiness  for line

* fix: center line inside a panel box

* fix: use color as a unique key
2020-01-16 00:07:19 +05:00
Timur Khazamov
79aee53ff6 Redesign idea ()
* Redisign idea

* Code cleanup

* Fixed to right container

* Reoredered layout

* Reordering panels

* Export dialog

* Removed redunant code

* Fixed not removing temp canvas

* Fixed preview not using only selected elements

* Returned file name on export

* Toggle export selected/all elements

* Hide copy to clipboard button if no support of clipboard

* Added border to swatches

* Fixed modal flickering
2020-01-15 07:42:02 -08:00
Preet
8dbd1b80df Update to rough.js 4.0.1 ()
* upgrade to latest rough.js

* remove random.ts because roughjs now supports seeding.
2020-01-13 11:04:28 -08:00
David Luzar
5887be6eda select filled elements by clicking inside () 2020-01-12 11:16:48 -08:00
Christopher Chedeau
407f00bbd5
Fix alt-duplicate ()
We need to unselect all the previous elements and select all the new ones. Also made sure that the shape is regenerated when the element is duplicated
2020-01-11 19:35:06 -08:00
Gasim Gasimzada
74764b06eb Regenerate roughjs shape only when the item is updated ()
* Regenerate roughjs shape only when the item is updated

* Remove shape object during export and history undo/redo

* Remove shape element during copying

* Fix shape generation during creation
2020-01-11 16:00:00 -08:00
dwelle
81f23a8ccb fix text shape contenteditable & paste handling (fixes ) 2020-01-10 15:51:22 +01:00
Gasim Gasimzada
f2346275ef
Extract Side Panel from App component ()
* Extract Side Panel from App component

* Refactor SidePanel component

- Remove unnecessary props (we are already passing appState as a prop)
- Remove unnecessary allback (we are already passing setState)
2020-01-10 18:00:19 +04:00
Gasim Gasimzada
862231da4f Make all operations on elements array immutable ()
* Make scene functions return array instead of mutate array

- Not all functions were changes; so the given argument was a new array to some

* Make data restoration functions immutable

- Make mutations in App component

* Make history actions immutable

* Fix an issue in change property that was causing elements to be removed

* mark elements params as readonly & remove unnecessary copying

* Make `clearSelection` return a new array

* Perform Id comparisons instead of reference comparisons in onDoubleClick

* Allow deselecting items with SHIFT key

- Refactor hit detection code

* Fix a bug in element selection and revert drag functionality

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-01-09 16:22:04 +01:00
Guillermo Peralta Scura
4a044d3ace Show move and resize cursors on hover ()
* Change to move cursor on hover

* Show resize handlers on hover
2020-01-08 18:56:35 -08:00
Gasim Gasimzada
299e7e9099
Extract app and keys ()
* Extract app component from entrypoint (index)

- Use refs to refer to canvas and rough context
- Remove ReactDOM double rendering

* Extract keys and key related utils into their own module

* Move everything back to entrypoint
2020-01-09 02:00:59 +04:00
Timur Khazamov
e38f65dea7
Contenteditable wysiwyg ()
* Contenteditable wysiwyg

* Added comment about pasting multiline text
2020-01-09 02:04:53 +05:00
Timur Khazamov
37934c0f8b
Fixes text jumping on creation ()
* Fixes text jumping on creation

* Do not remove node on ESC

* Fixed typo
2020-01-09 00:06:25 +05:00
David Luzar
2122a9cf9f
fix for duplicating elements () 2020-01-08 19:54:42 +01:00
dwelle
08b804ac63 ensure only selected elems can be resized (fixes ) 2020-01-08 18:06:04 +01:00
dwelle
009412a093 improve typing for handlerRectangles 2020-01-08 17:05:00 +01:00
Gasim Gasimzada
4b7eb2f04a
Add IDs to elements ()
* Add IDs to elements

- Move round rect function within the renderer

* Generate IDs using nanoid

* If element ID does not exist, add the ID during restoration
2020-01-07 23:49:39 +04:00
Faustino Kialungila
846f427732 adding comments about diamond dimensions () 2020-01-07 18:59:10 +01:00
Timur Khazamov
10955f8bb0 Wysiwyg text 2.0 ()
* Fixed cleaning handlers after cleanup

* Double click to edit text

* Preserve text styles on change
2020-01-07 09:21:05 -08:00
Gasim Gasimzada
829a65b8cb
Refactor Element Functions ()
* Remove `generatedraw` from element object

- Create a function that renders a single element
- Refactor rendering selected elements

* Replace getElementAbsoluteXY with getElementAbsoluteCoords
2020-01-07 19:04:52 +04:00
Christopher Chedeau
f2665408fc
Revert "Wysiwyg text ()" ()
This reverts commit abbc04df0e5a3b9265ada12a73bc9b8a810a329c.
2020-01-06 19:50:37 -08:00
Timur Khazamov
abbc04df0e Wysiwyg text () 2020-01-06 19:03:05 -08:00
Timur Khazamov
7bf0184499
Fixed ellipse hit test if sizes are negative () 2020-01-06 23:06:54 +05:00
Gasim Gasimzada
01805f734d
Extract element functions into modules () 2020-01-06 19:34:22 +04:00