201 Commits

Author SHA1 Message Date
Gasim Gasimzada
dab35c9033
Multi Point Lines (based on Multi Point Arrows) (#660)
* Enable multi points in lines

* Stop retrieving arrow points for lines

* Migrate lines to new spec during load

* Clean up and refactor some code

- Normalize shape dimensions during load
- Rename getArrowAbsoluteBounds

* Fix linter issues
2020-02-04 13:45:22 +04:00
Gasim Gasimzada
f70bd0081c
Feature: Hint viewer (#666)
* Add Hint viewer

- Add hints for arrows and lines
- Add hints for resizing elements

* Swap priority of multi mode and resize mode in Hint Viewer

* Remove dangling locales from public

* Add shortcut to hide hints

* Change hint texts and show resize hint ONLY during resizing

* Remove hints toggling
2020-02-03 09:52:21 -08:00
lissitz
92a0f100b8
Drag and drop JSON exports to canvas loads the scene (#676)
* Drag and drop JSON exports to canvas loads the scene

* remove unneeded onDragOver
2020-02-02 21:02:13 +00:00
Lipis
53994e71e5
Add more ESLint rules and change the formatting scripts (#626)
* Add curly rule in ESLint for consistency

* Fix rules

* More rules

* REturn

* Push

* no else return

* prefer const

* destructing
2020-02-02 18:04:35 +00:00
Christopher Chedeau
f8a41cee16
Add keybindings for shapes (#648)
* Add keybindings for shapes

I'm not 100% sure about this one. I feel like it's going to help people be a lot more productive to display the key bindings at all time. But it also clutters the UI...

* increase font-size

* fix shape keybindings for non-qwerty keyboards

* tweak position and color

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-02-01 18:31:28 +01:00
Christopher Chedeau
be97bd980e
Add button when scrolled outside of visible area (#643)
With the infinite scroll behavior, it's easy to scroll super far away from where the content is and have a hard time getting back. This PR adds a button to refocus on the center of the scene when no elements are visible anymore.
2020-02-01 17:52:10 +01:00
Faustino Kialungila
7c9e6dd3f1
support undo/redo for azerty keyboards (#630)
* support undo/redo for azerty keyboards

* migrate to event.key

* remove unnecessary shiftKey check

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-02-01 17:37:22 +01:00
Gasim Gasimzada
1e4ce77612
Reintroduce multi-point arrows and add migration for it (#635)
* Revert "Revert "Feature: Multi Point Arrows (#338)" (#634)"

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
47f6328ae1
Fix ability to use arrow keys to navigate between shapes (#646)
This is the only way to navigate using the keyboard and was prevented by #596. Now it works fine.

Test Plan:
- Click on selection icon
- Use left/right arrow keys to move between tool icons, that works.

- Click on a shape, cmd+c
- Click on the selection icon
- Cmd+v, it pastes correctly
2020-02-01 02:58:16 +00:00
Christopher Chedeau
29f1465b81
Fix wrong cursor for selection keyboard shortcut (#645)
Pressing 1 would change the cursor to a + instead of normal cursor
2020-02-01 02:57:44 +00:00
Christopher Chedeau
e4919e2e6c
Replace i18n by a custom implementation (#638)
There are two problems with the current localization strategy:
- We download the translations on-demand, which means that it does a serial roundtrip for nothing.
- withTranslation helper actually renders the app 3 times on startup, instead of once (I haven't tried to debug it)
2020-01-31 21:06:06 +00:00
Christopher Chedeau
637276301a
Different call of resumeRecording() (#636)
Instead of finding all the places where we want to resume recording, we should do it after every componentDidUpdate(). The idea is that we just want to disable the history for certain setState, for which we call directly before skipHistory.
2020-01-31 21:09:42 +01:00
David Luzar
3d2e59bfed
Revert "Feature: Multi Point Arrows (#338)" (#634)
This reverts commit 16263e942b7b690bb3e97340383009016129d489.
2020-01-31 18:56:55 +01:00
Gasim Gasimzada
16263e942b
Feature: Multi Point Arrows (#338)
* 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
6886dfdea7
ensure we reset draggingElement when tool locked (#627) 2020-01-30 22:14:40 +01:00
Guillermo Peralta Scura
35750d8d09
Panning with space key (#579)
* Panning with space key

* prevent panning when selecting/dragging & add more checks

* Fix changing current tool via shortcut while panning

* Fix order of statements

* teardown on blur event

* Refactor cursor setting

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-01-30 17:08:59 -03:00
Robinson Marquez
4ad38e317e
485: Ability to switch to previously loaded ids in UI (#583) 2020-01-30 21:39:37 +02:00
David Luzar
bd1c00014b
fix not resuming recording (#614) 2020-01-30 15:39:17 +01:00
Preet
97b11b0f53
SVG export (#598)
* first draft of export to SVG. WIP

* enabled text rendeing - which is not quite right atm

* placeholder svg icon

* size the canvas based on the bounding box of elements

* Do not add opacity attributes if default

* render background rect

* Ensure arrows are in the same SVG group

* parse font-size from font

* export web fonts

* use fixed locations for fonts

* Rename export functions

* renamed export file

* oops broke the icon.
2020-01-28 12:25:13 -08:00
lissitz
845484aecc Fix: refreshing the page while selecting saves the selection ele… (#601)
* Fix: refreshing the page while selecting saves the selection element

Fixes #591.

* fix lint

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-01-28 16:44:34 +01:00
David Luzar
26048ee469
improve clipboard handling (#596)
* improve clipboard handling

* fix regression of not defocusing tool icons
2020-01-27 22:14:35 +01:00
David Luzar
187cfbe2d8
temp hack fix for state updates (#593)
* temp hack fix state updates

* switch setTimeout for state mutation
2020-01-27 19:24:11 +01:00
Guillermo Peralta Scura
67eca2bda1
Add landmarks (#564)
Use HTML semantic elements to set the landmarks of the page.

This is helpful for assistive technologies to determine the different regions of content. In our case it's useful for jumping between the different islands that we use to group the form controls.
2020-01-26 17:14:31 -03:00
Lipis
81d169e90c Add tool tip for shape lock (#551)
* Add tool tip for shape lock

* tweak label & fix master rebase

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-01-26 21:00:00 +01:00
David Luzar
7b842fc330 simplify distance helper and factor out common bounds helper (#581)
* simplify distance helper

* factor out common bounds helper
2020-01-26 19:15:08 +00:00
Christopher Chedeau
8ab176b9a5
Disable UI rendering when history is skipped (#574)
When we are scrolling, resizing, or moving elements, we already disable the history. Since those actions do not change the state of the UI, we can also avoid re-drawing it and save ~10ms per frame.

I had to change all the forceUpdate() to setState({}), otherwise it would bypass shouldComponentUpdate.
2020-01-26 19:08:46 +00:00
Christopher Chedeau
263fef4eaa
Add a gap between shapes and lock (#569)
* Add a gap between shapes and lock

The lock is a different type as the rest of the shapes, so we should visually separate it.

* redesign lock icon

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-01-26 19:01:56 +00:00
Christopher Chedeau
141b7409a2 Only show correct settings (#565)
* Only show correct settings

The logic to display which settings when nothing was selected was incorrect. This PR ensures that they are in sync.

I also removed all the <hr /> which after the redesigned just looked like weird empty spaces

* fix handling editing/text elements

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-01-26 15:19:43 +01:00
Christopher Chedeau
2a87c7381b Set selection when unlocking (#567)
A common workflow I have is to enable the lock, draw a bunch of things, unlock to be able to select stuff. However, after I unlock, the last shape is still enabled, so I end up drawing yet another of the same shape :(

This PR resets to selection instead!
2020-01-26 14:24:50 +01:00
Christopher Chedeau
e1ed40be65 Fix exported size when drawing to the left (#575)
If you scroll and draw to the left of the origin, when you export the scene, there's a weird whitespace on the right. This is because we do the min() computation starting at 0 and not -Infinity

This also fixes pasted elements and scrollbars.
2020-01-26 12:28:15 +01:00
Christopher Chedeau
c3e9f775e7 Disable escape when creating element (#576)
Problem:
- Select arrow
- Mouse down somewhere
- Mouse move somewhere to create an arrow
- Press escape
- Now you're in a weird situation where the shape is now "selection" but you're still dragging the arrow. If you mouse up, the arrow disappears

In order to solve this problem, we can avoid making escape do anything if you're currently dragging an element
2020-01-26 11:36:05 +01:00
Christopher Chedeau
c697938350
Do not store cursor position in state (#557)
* Do not store cursor position in state

Storing it in state causes a full re-render. The only time we use the cursor position is for pasting. This halves the number of renders on drag.

* remove passive change
2020-01-25 11:38:08 -08:00
lissitz
1bae203a78 changing new shape property sets it as default (#520)
* 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
Guillermo Peralta Scura
69061e20ac Some a11y fixes (#534)
* Rename ToolIcon to ToolButton

It makes more semantic sense

* Label and keyboard shortcuts announcement

* Refactor common props for ToolButton

* Better doc outline and form controls

* Adjust color picker

* Styling fixes

Co-authored-by: Christopher Chedeau <vjeuxx@gmail.com>
2020-01-25 09:52:03 -08:00
Loris
413c387c7c Add onCancel callback to textWysiwyg for cleanup (#555) 2020-01-25 09:45:23 -08:00
Bakhtiiar Muzakparov
689c94151d fix: typos (#540) 2020-01-24 21:02:55 +01:00
David Luzar
afb1d6725f
Normalize dimensions (#527)
* normalize dimensions of non-linear elements

* fix element type check regression
2020-01-24 20:45:52 +01:00
Faustino Kialungila
54f9c296b5
Enhance language selection (#538)
* Enhance language selection

* remove top/left margin to limit unusable canvas area

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-01-24 19:10:44 +01:00
Lipis
ee68af0fd3
Set Trailing Cmma to (#525) 2020-01-24 12:04:54 +02:00
Thibaut SABOT
e8c909e35c Don't use translated value for shortcut (#526) 2020-01-23 18:28:05 +02:00
Günay Mert Karadoğan
926b4f24e6 Draw horizontal/vertical lines/arrows when shift pressed (#430)
* 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
Enzo Ferey
dfb7c2b744 Add app state to history (#309)
* Add app state to history.

* Pick missing state keys.

* Fix bug.

* Remove force update.
2020-01-22 21:32:43 +01:00
Lipis
48024c9116
Remove selected object when storing to backend (#506) 2020-01-22 18:27:44 +02:00
Fernando Alava Zambrano
a436e70764 Internationalization followup (#500)
* add translations in data.ts

* add language list
add spanish version

* fixes pr review

* add more translations

* remove unused label

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-01-22 16:25:04 +02:00
Bakhtiiar Muzakparov
bef279417e fix: cursor on keyboard tool toggle (#482)
* update events for GH actions to include PRs

* fix: cursor on keyboard tool toggle

* fix: change cursor type to constant

* fix: swap condition

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-01-22 14:36:08 +01:00
David Luzar
20cf1078fc
add top error boundary & reset localStorage on error (#493)
* add top error boundary & reset localStorage on error

* add issue tracker details and link

* add pointer cursor to buttons

* Update src/bug-issue-template.js

Co-Authored-By: Lipis <lipiridis@gmail.com>

* Update src/styles.scss

Co-Authored-By: Lipis <lipiridis@gmail.com>

* Update src/bug-issue-template.js

Co-Authored-By: Lipis <lipiridis@gmail.com>

* use open-color colors

* use Cascadia font

Co-authored-by: Lipis <lipiridis@gmail.com>
2020-01-21 15:50:25 +01:00
Jilles Soeters
a72a143c84 Introduce Shapelock (#480)
* Introduce shape lock

* Format code with prettier

* Do not reset elementLocked on selection change

* Don't set isSelected to true if element is locked

* Don't reset the cursor

* Move reset cursor call to better spot

* Run prettier + lint
2020-01-20 15:52:19 -08:00
David Luzar
2340dddaad Sync panel props to editing element (#470)
* ensure panel props are sync to editing elem

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

* remove dead code

Co-authored-by: Christopher Chedeau <vjeuxx@gmail.com>
2020-01-20 15:16:22 -08:00
Fernando Alava Zambrano
ff7a340d2f Internationalization support (#477)
* add i18next lib
add some translations

* add translations

* fix font-family

* fix pin versions
2020-01-20 15:14:10 -08:00
Panayiotis Lipiridis
703d1e42e3 id instead of json 2020-01-20 21:30:07 +02:00