409 Commits

Author SHA1 Message Date
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
Lipis
9a17abcb34
Cleanup .gitignore (#629) 2020-01-31 13:55:53 +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
David Luzar
023400c3cc
Revert "Fix keyboard shortcut (#587)" (#617)
This reverts commit cc3d71f13c0604406eda838344d99866dd94df39.
2020-01-30 10:40:49 +01:00
Bakhtiiar Muzakparov
cc3d71f13c
Fix keyboard shortcut (#587)
* Fix keyboard shortcut

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-01-29 16:31:49 +00:00
Bakhtiiar Muzakparov
63c685af73
Add russian translation (#612) 2020-01-29 14:00:47 +00:00
Lipis
82717bceda
Remove eslint-plugin-json-format (#609)
* Remove eslint-plugin-json-format

* json
2020-01-29 11:26:40 +01:00
Panayiotis Lipiridis
5418f68cc5 Update deps 2020-01-29 03:05:00 +02:00
Lipis
2dce2ce712
Show labels instead of icons for PNG, SVG (#606) 2020-01-29 02:30:02 +02:00
Lipis
a9790c74f5
Wider export dialog (#603) 2020-01-29 02:26:02 +02:00
Lipis
ba4fc0f1b3
Minor redesign of Export Dialog (#604) 2020-01-29 02:25:47 +02: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
Lipis
321e4022b0
Add headers for Netlify (#602) 2020-01-28 21:15:24 +02: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
Faustino Kialungila
de68561df5
lowercase pasted color (#594)
* lowercase pasted color

* remove unused class & don't lowercase input

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-01-27 19:51:11 +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
Thomas Steiner
a862d12ac1
Bump browser-nativefs version to v0.2.0 (#586)
* Bump browser-nativefs version to v0.2.0

In reply to https://github.com/tomayac/browser-nativefs/issues/2.

* Update package-lock.json
2020-01-27 10:14:44 +01:00
Guillermo Peralta Scura
2363afa864
Fix Spanish translation (#585) 2020-01-26 17:27:17 -03: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
fc350f2ecd Adjust language selector (#552)
* Adjust language selector

* rem
2020-01-26 21:04:56 +01: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
61264ee2d6
move title to label (#584) 2020-01-26 20:49:18 +01:00
David Luzar
e17f743df1 change cartoonist roughness (#582) 2020-01-26 19:16:33 +00: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
5853fba821
Fix global settings (#572)
Some PR made the settings UI show up even though nothing is selected. However, you couldn't actually change any of those settings except for the colors. This PR pipes through the rest of the properties so everything works now!
2020-01-26 19:09:11 +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
ed42672fd3 Fix value when multiple elements are selected (#571)
If you have two elements selected that have a different value (eg: a green line and a red line), the value of the color picker should be undefined, not the default value.
2020-01-26 13:12:47 +01:00
Christopher Chedeau
3e381b75cb Remove image type description when saving to png (#566)
The description is the name of the file type in the dialog. This shouldn't be Excalidraw but the default one for a png.
2020-01-26 13:04:33 +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
4b0f788945
Proper error handling for creating a link without internet (#577)
* Proper error handling for creating a link without internet

* shuffle code a bit

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-01-26 03:06:37 -08:00
Christopher Chedeau
1d9cdf4d46 Use local fonts (#573)
This updates the way fonts are handled to not have to download the font from the internet.

If you do `./public/font.ttf` in the .scss file, unfortunately the bundle packages them somewhere that's different from the public folder that is used by the index.html to preload them.

The fix I used is to use absolute path `/font.ttf` so that both work. Unfortunately, this means that the website will only work if at the root of the domain. That's the case so far so it's okay but still annoying if we want to embed it somewhere.
2020-01-26 11:46:56 +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
94e18bd8e4 Untranslated lock icon (#568)
Sorry my OCD is kicking in... It's super weird that the base of the lock moves when we check / unckeck it. Instead, just the semi-circle shape should move (what this PR implements).
2020-01-26 11:34:15 +01:00
Christopher Chedeau
61f301c3e0 Cleanup saved json file (#578)
It turns out the only thing we need to save in the appState is the background color. All the rest is transient data.

I added `"type": "excalidraw"` at the beginning to explain where it was.

I removed `"source": "http://localhost:3000/"`. I don't think we want to leak on which webpage it was saved from.

I removed `isSelected` from the json

I added indentation so it's easier to read the content. I'm not 100% sure on this one, but I figure filesize doesn't matter too much those days. And if we want to shrink it, there are more effective ways than json.
2020-01-26 11:30:34 +01:00
Lipis
3901ad7dbe Adjust context menu and use open colors (#553)
* Adjust context menu and use open colors

* word wrap

* revert colors & padding

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-01-26 11:19:21 +01:00
Guillermo Peralta Scura
e4ff408f23
Accessible modals (#560)
Improve the accessibility of our modals (the color picker and the export dialog)

Implement a focus trap so that tapping through the controls inside them don't escape to outer elements, it also allows to close the modals with the "Escape" key.
2020-01-25 19:37:58 -03:00
Christopher Chedeau
ba13f88924
Do not trigger modal actions when not visible (#562)
Right now we're running useEffect block which runs getExportCanvasPreview on every state update, even if the modal is not visible (eg: when moving the mouse around!). This puts the modal code in its own component so that it doesn't trigger useEffect when not visible.

The code isn't very elegant as we're forwarding all the props, there's likely a better way to handle it (if anyone is interested, PR would be appreciated), but at least now it no longer double renders the scene.

Fixes #559
2020-01-25 14:11:26 -08: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
Christopher Chedeau
5b19aeafe9
Make color selection accessible (#556)
By changing from a `<div>` to a `<button>`, it's now possible to use the space key in order to select it
2020-01-25 10:11:57 -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
Marco Kaul
5fd6c4d853 Add german translation (#550)
* Add german translation

* Add german language option

* Fix missing german translation

* Alphabetical order for languages

* Sort

Co-authored-by: Lipis <lipiridis@gmail.com>
2020-01-25 09:47:02 -08:00