Commit Graph
94 Commits
Author SHA1 Message Date
Christopher ChedeauandGitHub 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 ChedeauandGitHub c7eebd42c1 Fix conflict (#641) 2020-01-31 21:51:35 +00:00
Christopher ChedeauandGitHub ead9aab888 Remove enzyme (#640)
The test that was added is not a good test. If we want to test things, we should be testing logic that is error prone such as all the mouse handling logic and state management. Adding a test for something trivial as displaying a list of data is just going to be annoying when we eventually change the UI and the test breaks.

Since this is the only test using enzyme, I also removed enzyme. We can add it back if we want to test a component using it.
2020-01-31 21:32:09 +00:00
Christopher ChedeauandGitHub 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 ChedeauandGitHub 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
Christopher ChedeauandGitHub 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 ChedeauandGitHub 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
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 ChedeauandDavid Luzar 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 ChedeauandDavid Luzar 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 ChedeauandFaustino Kialungila 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 ChedeauandDavid Luzar 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 ChedeauandDavid Luzar 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
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 ChedeauandDavid Luzar 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 ChedeauandDavid Luzar 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 ChedeauandDavid Luzar 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 ChedeauandDavid Luzar 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
Christopher ChedeauandGitHub 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 ChedeauandGitHub 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 ChedeauandGitHub 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
Christopher ChedeauandGitHub 7f6e1f420e Pure node rendering (#443) 2020-01-19 13:21:33 -08:00
Christopher ChedeauandGitHub f91b708abb Revert "Shift drag to add to selection (#350)" (#352)
This reverts commit ce467f7b65.
2020-01-12 12:08:18 -08:00
Christopher ChedeauandGitHub bc909b76da Move copy paste handler to document (#334)
Hopefully it should resolve the copy pasting issues

Fixes #249
2020-01-11 21:39:16 -08:00
Christopher ChedeauandGitHub aad6e8f434 Reset to selection after creating a text (#333)
Fixes #252

Test plan:
- Click on text icon
- Click anywhere to start entering text
- Add a letter
- Make sure the cursor is selection and not text
- Click anywhere else, make sure it completes the text and not create a new one
2020-01-11 21:00:55 -08:00
Christopher ChedeauandGitHub 44657efe71 Fix undoOnce (#332)
I just pasted @enzoferey's implementation and it fixed the bug reported by @dwelle

Fixes #307
2020-01-11 20:45:56 -08:00
Christopher ChedeauandGitHub dd2a7eb597 Fix copy-paste on input (#331)
If the input is active, we shouldn't override copy paste behavior
2020-01-11 20:41:47 -08:00
Christopher ChedeauandGitHub d45f48e60f Set shape background to be transparent by default (#330)
Also makes "Clear canvas" reset the entire app state
2020-01-11 20:34:21 -08:00
Christopher ChedeauandGitHub 3db7d69849 Debounce localstorage save (#328)
I profiled dragging and it looks like it takes ~3ms to save to localStorage a smallish scene and we're doing it twice per mousemove. Let's debounce so we don't pay that cost on every mouse move.

Stole the implementation from #220 which got reverted.
2020-01-11 20:15:41 -08:00
Christopher ChedeauandGitHub c745fd4e5e Prevent cmd-r from selecting rectangle (#327)
I keep adding empty rectangles because I reload with cmd-r which enables rectangle :p Let's only make the shortcut work if there's no modifier enabled
2020-01-11 19:42:34 -08:00
Christopher ChedeauandGitHub 407f00bbd5 Fix alt-duplicate (#326)
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
Christopher ChedeauandGitHub 8785bef523 Support transparent background + inline picker (#325)
Unfortunately, react-color has a bug where transparent color doesn't trigger onChange. I've been annoyed by the huge dependency anyway so decided to take the generated html (which is awesome) and reimplement a specific component for it.

I also made sure that we don't actually render anything when the background is transparent on rough (I looked at the generated path and made sure it didn't have the commands for the background)
2020-01-11 19:10:41 -08:00
Christopher ChedeauandGitHub 157f0eae0c Export to canvas only selected elements (#323)
Fixes #308
2020-01-11 16:15:26 -08:00
Christopher ChedeauandGitHub 9fa69448e4 Remove Delete from panel (#322)
Now that we have context menu, we don't need it there
2020-01-11 16:11:21 -08:00
Christopher ChedeauandGitHub 5bdd0a35f6 Fix cmd-a drawing arrows (#321)
We need to quit if we have either elements OR appState, not both.
2020-01-11 16:06:25 -08:00
Christopher ChedeauandGitHub 1bf18fe4ed Tweak context menu style (#320)
- Move the context menu right next to the mouse so it's not so far away. But 1px out so that nothing is selected until you move your mouse
- Change the colors to be closer to the macos one. Unfortunately, macos has a 0.5px border that I'm not able to reproduce without some annoying hacks, 1px it'll be.
2020-01-11 15:59:42 -08:00
Christopher ChedeauandGitHub b481a29024 Remove console.log (#317) 2020-01-11 15:21:24 -08:00
Christopher ChedeauandGitHub 6399b1f318 Remove zindex options from panel (#315)
Now that they are in the context menu, we don't need to have them in the panel anymore.

Fixes #242
2020-01-11 14:58:11 -08:00
Christopher ChedeauandGitHub 2553d10d34 Yet another awesome testimonial (#282) 2020-01-08 20:49:42 -08:00
Christopher ChedeauandGitHub 77400c7b70 One more testimonial (#281) 2020-01-08 19:58:19 -08:00
Christopher ChedeauandGitHub 556843d9a2 Adding open collective sponsor (#275)
I just created an open collective for the project.
2020-01-08 13:04:13 -08:00
Christopher ChedeauandGitHub f2665408fc Revert "Wysiwyg text (#200)" (#225)
This reverts commit abbc04df0e.
2020-01-06 19:50:37 -08:00
Christopher ChedeauandGitHub 8a91f4fe7b One more testimonial (#221) 2020-01-06 13:57:04 -08:00
Christopher ChedeauandGitHub 3bbcb9cbdc Improve Color Picker *2 (#195) 2020-01-05 19:57:50 -08:00
Christopher ChedeauandGitHub 23cd62d148 Improve selection view (#192) 2020-01-05 19:11:35 -08:00
Christopher ChedeauandGitHub fd6b5024c7 Reorganize menu (#178) 2020-01-05 14:45:16 -08:00
Christopher ChedeauandGitHub 6f33d72e35 Add MIT License (#176)
I have no idea if previous people have to agree or what but let’s put a MIT license in.
2020-01-05 13:09:29 -08:00
Christopher ChedeauandGitHub 06b77326bf One more testimonial (#162) 2020-01-05 10:09:36 -08:00
Christopher ChedeauandGitHub 3605250426 Move octocat to the front (#160) 2020-01-05 09:58:47 -08:00
Christopher ChedeauandGitHub b24d1423a5 Tweak README (#158)
- Add first testimonial
- Rename "getting started" to "run the code"
- Added zwibbler shoutout
2020-01-05 09:54:54 -08:00
Christopher ChedeauandGitHub 85fe9f85fb Fix missing mouseup (#144) 2020-01-04 18:36:49 -08:00
Christopher ChedeauandGitHub 9e5c5daf64 Cmd-Z (#141) 2020-01-04 16:59:59 -08:00
Christopher ChedeauandGitHub 4ca8f65887 Use device pixel ratio (#139)
* Use device pixel ratio

* Update index.tsx
2020-01-04 16:08:35 -08:00
Christopher ChedeauandGitHub 3172109050 Inline font-awesome icons (#134) 2020-01-04 12:47:12 -08:00
Christopher ChedeauandGitHub 60b06dab73 Remove manifest.json (#131) 2020-01-04 12:19:39 -08:00
Christopher ChedeauandGitHub bd86f819df Prevent re-assignment of elements (#121) 2020-01-04 10:48:23 -08:00
Christopher ChedeauandGitHub 25aabdc4d1 Fix hit testing (#119) 2020-01-04 10:19:18 -08:00
Christopher ChedeauandGitHub 4886065443 Wire up forward (#101)
* Wire up forward

* Match words with Keynote/Powerpoint
2020-01-03 21:46:49 -08:00
Christopher ChedeauandGitHub 6b8d2970ac Add support for forward (#100) 2020-01-03 21:38:48 -08:00
Christopher ChedeauandGitHub 0d5272720f Send to back (#98) 2020-01-03 21:03:25 -08:00
Christopher ChedeauandGitHub 66938ae5c6 Update on resize (#94)
Fixes #88
2020-01-03 18:35:14 -08:00
Christopher ChedeauandGitHub 8605af2b54 Fix key warning (#93) 2020-01-03 18:32:23 -08:00
Christopher Chedeau c077403eec Generate new seed on paste 2020-01-03 18:29:46 -08:00
Christopher ChedeauandGitHub aad99b3047 Update README.md 2020-01-03 18:19:58 -08:00
Christopher ChedeauandGitHub 85cd2f114a Add github corner (#90) 2020-01-03 18:16:27 -08:00
Christopher ChedeauandGitHub 929efa5e2c Distance between point and ellipsis (#92) 2020-01-03 18:16:16 -08:00
Christopher ChedeauandGitHub c027ddc134 Add analytics tag (#89) 2020-01-03 15:47:15 -08:00
Christopher ChedeauandGitHub b18a0efe2c Seed (#73) 2020-01-03 12:33:52 -08:00
Christopher ChedeauandGitHub a5b0e192b4 Remove drawScene (#58) 2020-01-02 19:47:32 -08:00
Christopher ChedeauandGitHub 4c94976527 Random fixes (#57) 2020-01-02 18:20:08 -08:00
Christopher ChedeauandGitHub 3b919f3235 Cmd-A to select everything (#51) 2020-01-02 14:42:53 -08:00
Christopher ChedeauandGitHub 278fc11d22 Better selection click detection (#50) 2020-01-02 14:33:45 -08:00
Christopher ChedeauandGitHub 8a43ed691d Handle escape keybinding (#49) 2020-01-02 14:10:32 -08:00
Christopher ChedeauandGitHub 0d75b78374 Path-dependent hit test (#48)
* Hit test

* Hit test

* Hit test
2020-01-02 13:47:50 -08:00
Christopher ChedeauandGitHub b6c30c0550 Copy paste (#44)
* Copy Paste

* Copy paste
2020-01-02 12:49:06 -08:00
Christopher Chedeau 44ff545219 Fix text height 2020-01-01 22:15:27 -08:00
Christopher Chedeau afe6331c61 Reset selection when adding text 2020-01-01 22:09:12 -08:00
Christopher Chedeau ee7dc953bf Fix clearRect for [0, 0.5] 2020-01-01 21:51:13 -08:00
Christopher Chedeau 457800caa3 Mouse move tracked outside window! 2020-01-01 21:46:42 -08:00
Christopher Chedeau 9aaaa24426 Also for text 2020-01-01 21:13:01 -08:00
Christopher Chedeau 2fa00f39fc Automatically select last inserted element 2020-01-01 21:10:56 -08:00
Christopher Chedeau c26d04e162 Don't write null when cancelling text 2020-01-01 21:03:44 -08:00
Christopher Chedeau ab84b5a048 Go to selection mode after adding a shape 2020-01-01 21:01:40 -08:00
Christopher Chedeau f8873dd56b Do not regenerate shapes when moving 2020-01-01 20:56:18 -08:00
Christopher Chedeau bd515f7e50 Real 1px lines 2020-01-01 20:21:47 -08:00
Christopher Chedeau 4076cf003f Proper fix for negative width 2020-01-01 20:13:06 -08:00
Christopher Chedeau 3c8eb862f5 Move with arrow keys 2020-01-01 20:02:09 -08:00
Christopher Chedeau 48d9147d87 Fix selection from right to left 2020-01-01 19:53:22 -08:00
Christopher Chedeau aeb11989e3 Fix text selection 2020-01-01 18:12:49 -08:00
Christopher Chedeau 3769c4af00 Handle backspace 2020-01-01 17:58:28 -08:00
Christopher Chedeau 9dc19dde1d Proper text sizing 2020-01-01 17:51:14 -08:00
Christopher ChedeauandGitHub 47e626f510 Add selection (#1) 2020-01-01 17:12:42 -08:00
Christopher Chedeau 6278cd9366 Initial commit 2020-01-01 17:04:47 -08:00
Christopher ChedeauandGitHub ec23829fce Initial commit 2020-01-01 17:04:44 -08:00