141 Commits

Author SHA1 Message Date
Pete Hunt
8d8f9f23bd
Make gesture.pointers a Map instead of an array of pointers (#877) 2020-03-08 19:25:16 -07:00
Pete Hunt
92ba401da8
Pull onPointerDown, onDoubleClick, onPointerMove into instance methods (#876)
* Pull onPointerDown, onDoubleClick, onPointerMove into instance methods

* Use bound instance methods
2020-03-08 18:09:45 -07:00
Pete Hunt
c89584832d
Reset selectedElementIds when deleting selected elements (#875) 2020-03-08 14:10:42 -07:00
Pete Hunt
ccbbdb75a6
Refactor ExcalidrawElement (#874)
* Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement.

* Fix most unit tests. Fix cmd a. Fix alt drag

* Focus on paste

* shift select should include previously selected items

* Fix last test

* Move this.shape out of ExcalidrawElement and into a WeakMap
2020-03-08 10:20:55 -07:00
Jed Fox
c6a0cfc2b1
Refactor (#862)
* Initial factoring out of parts of the LayerUI component

2360 → 2224 LOC

* Create a Section component

* Break up src/index.tsx

* Refactor actions to reduce duplication, fix CSS

Also consolidate icons

* Move scene/data.ts to its own directory

* Fix accidental reverts, banish further single-character variables

* ACTIVE_ELEM_COLOR → ACTIVE_ELEMENT_COLOR

* Further refactoring the icons file

* Log all errors

* Pointer Event polyfill to make the tests work

* add test hooks & fix tests

Co-authored-by: dwelle <luzar.david@gmail.com>
2020-03-07 16:20:38 +01:00
Jed Fox
8e0206cc1e
Undo/Redo buttons, refactor menu toggles (#793)
* Make Undo & Redo and the menu buttons into actions; add undo/redo buttons

* Create variables for the ToolIcon colors

* Darken the menu buttons when they’re active

* Put the more intensive test in `perform`

* Fix & restyle hint viewer

* Add pinch zoom for macOS Safari

* Chrome/Firefox trackpad pinch zoom

* openedMenu → openMenu

* needsShapeEditor.ts → showSelectedShapeActions.ts

* Call showSelectedShapeActions
2020-03-01 20:39:03 +01:00
Lipis
097c5dfad7
Refactor: e -> event or error, err -> error, p -> pointer (#831)
* Refactor: e -> event or error, err -> error, p -> pointer

* simplify
2020-02-28 23:03:53 +01:00
Takumi
a613d02147
Add cursor pointer style to hidden radio buttons (#810)
* Add cursor pointer style to hidden radio buttons

* ensure hidden input buttons don't interact with mouse

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-02-22 20:26:06 +01:00
Oren Me
07336bb168
feat: add reset zoom button (#777)
* feat: add reset zoom button

Add zoom reset button.
Button is shown only when zoom scale is different from 1

* change reset zoom icon

* always show zoom reset

* fix typo
2020-02-22 20:24:34 +01:00
Jed Fox
74add8661a
Fix error on export (#808) 2020-02-22 07:46:12 -08:00
Jed Fox
43236bed68
Fix error with contentEditable (#803) 2020-02-21 19:51:34 -08:00
Jed Fox
0fd3fb4b5b
More mobile tweaks (#790)
* Disable text selection

* Set content-editable=plaintext-only to disable Touch Bar formatting buttons

* Enlarge resize handle tap targets for pen/touch

* Make the lock button a button in mobile mode

* Use icons instead of Unicode characters; add an alternate toolbar for creating multipoint lines

* Allow buttons to hide themselves

* Fix heuristic for showing shape actions

* Refactor icons

* Fix label for edit button

* Switch edit button icon

* Remove lock button on mobile

* Add language selector on mobile

* Fix showing edit button on mobile

* Fix showing edit button on mobile, part 2

* Fix handle touch regions

* Fix scroll-back button position

* Allow using the text tool on a text object to start editing it

* Fix deletion of last point in line
2020-02-21 11:34:18 -08:00
Lipis
949c3841ea
Show hint under toolbar (#783) 2020-02-21 17:04:54 +01:00
Jed Fox
ab176937e6
Add touch support (#788)
* Add touch support

* Mock media query

* Mock media query pt 2

* Fix tests

* Allow installing as an app on iOS

* Fix type error

* Math.hypot

* delete and finalize buttons, hint viewer

* skip failing tests

* skip the rest of the failing tests

* Hide the selected shape actions when nothing is selected

* Don’t go into mobile view on short-but-wide viewports

* lol
2020-02-21 08:17:20 -05:00
Jed Fox
7a7a73b78d
Initial support for mobile devices (#787)
* Initial support for mobile devices

No editing yet, but UI looks nice and you can open the canvas menu

* Add support for editing shape color, etc

* Allow the mobile menus to cover the shape selector

* Hopefully fix test error

* Fix touch on canvas

* Fix safe area handling & remove unused Island
2020-02-20 15:44:38 -08:00
Sosuke Suzuki
2bb95f0651
Modify to avoid to blur while composing (#775) 2020-02-17 09:44:08 +01:00
Enzo Ferey
6ebd41734f
Resize handler detection should not be active when moving multip… (#767)
* Fix bug.

* Implement `getSelectedElements`.

* Explicit condition.

* Respect variable naming.

* Keep state consistent.

* Use `isSomeElementSelected` abstraction.

* Missing ones.
2020-02-16 22:54:50 +01:00
Enzo Ferey
c7ff4c2ed6
Canvas zooming (#716)
* Zoom icons.

* Actions.

* Min zoom of 0 does not make sense.

* Zoom logic.

* Modify how zoom affects selection rendering.

* More precise scrollbar dimensions.

* Adjust elements visibility and scrollbars.

* Normalized canvas width and height.

* Apply zoom to resize test.

* [WIP] Zoom using canvas center as an origin.

* Undo zoom on `getScrollBars`.

* WIP: center zoom origin via scroll

* This was wrong for sure.

* Finish scaling using center as origin.

* Almost there.

* Scroll offset should be not part of zoom transforms.

* Better naming.

* Wheel movement should be the same no matter the zoom level.

* Panning movement should be the same no matter the zoom level.

* Fix elements pasting.

* Fix text WYSIWGT.

* Fix scrollbars and visibility.
2020-02-15 21:03:32 +01:00
David Luzar
389e40900c
z-index button fixes (#738)
* fix svg attributes

* center z-index icons

* remove unnecessary attributes

* differentiate button :active bg

* prevent selection of ToolIcon hints

* emphasize active elem color
2020-02-09 17:09:21 +01:00
Christopher Chedeau
935a7f58a7
Remove previously loaded scenes (#734)
As mentioned in #724, the current implementation is suboptimal. Let's remove it until we come back with a better design.

Fixes #724
2020-02-08 15:05:38 -08:00
Gasim Gasimzada
33016bf6bf
Fix issues related to history (#701)
* Separate UI from Canvas

* Explicitly define history recording

* ActionManager: Set syncActionState during construction instead of in every call

* Add commit to history flag to necessary actions

* Disable undoing during multiElement

* Write custom equality function for UI component to render it only when specific props and elements change

* Remove stale comments about history skipping

* Stop undo/redoing when in resizing element mode

* wip

* correctly reset resizingElement & add undo check

* Separate selection element from the rest of the array and stop redrawing the UI when dragging the selection

* Remove selectionElement from local storage

* Remove unnecessary readonly type casting in actionFinalize

* Fix undo / redo for multi points

* Fix an issue that did not update history when elements were locked

* Disable committing to history for noops

- deleteSelected without deleting anything
- Basic selection

* Use generateEntry only inside history and pass elements and appstate to history

* Update component after every history resume

* Remove last item from the history only if in multi mode

* Resume recording when element type is not selection

* ensure we prevent hotkeys only on writable elements

* Remove selection clearing from history

* Remove one point arrows as they are invisibly small

* Remove shape of elements from local storage

* Fix removing invisible element from the array

* add missing history resuming cases & simplify slice

* fix lint

* don't regenerate elements if no elements deselected

* regenerate elements array on selection

* reset state.selectionElement unconditionally

* Use getter instead of passing appState and scene data through functions to actions

* fix import

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-02-05 19:47:10 +01:00
Christopher Chedeau
2dd1796351
Add encryption (#642)
* Add encryption

In order to avoid the server being able to read the content of the scene, this PR implements local encryption and decryption. This implements the algorithm described in #610.

Right now the server doesn't support uploading binary files. I mocked the server with comments. @lipis, could you add support on the server and update this PR? I added a bunch of TODO: that tell you where to comment/uncomment in order to get the server flow going.

To test locally right now:
- Import: Open http://localhost:3000/#json=1234,5oYVOnGpWYPPTz19-PMYYw and see a square
- Export: Click the export link and see the right url with the private key + the encrypted binary in the console

Fixes #610

* backend_v2

* v2
2020-02-05 07:35:51 -08:00
BM
27a1217981
Remove select color input on click (#708) 2020-02-05 04:04:29 +00:00
Bakhtiiar Muzakparov
173fe093b6
Fix typing into color picker popup text field (#694)
Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-02-04 13:28:22 +00:00
David Luzar
954d805cb3
rewrite clipboard handling (#689) 2020-02-04 11:50:18 +01: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
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
46791e6da1
Add keybindings for color picker (#647)
* Add keybindings for color picker

This adds the ability to navigate using left/right/bottom/up keys and shows key bindings for all the different colors. This is only optimized for the qwerty keyboard layout, but unfortunately it's not possible to detect other keyboard layouts :(

* add aria-keyshortcuts and keybinding in title

* make focus select color, confirm on enter

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-02-01 13:56:15 +01:00
Christopher Chedeau
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 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
Robinson Marquez
4ad38e317e
485: Ability to switch to previously loaded ids in UI (#583) 2020-01-30 21:39:37 +02: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
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
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
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
David Luzar
61264ee2d6
move title to label (#584) 2020-01-26 20:49:18 +01: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
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
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
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
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
Bakhtiiar Muzakparov
689c94151d fix: typos (#540) 2020-01-24 21:02:55 +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