21 Commits

Author SHA1 Message Date
Lipis
c427aa3cce
Prefer arrow functions and callbacks (#1210) 2020-05-20 15:21:37 +02:00
Pete Hunt
bd7856adf3
Much more thorough tests! (#1053) 2020-03-23 16:38:41 -07:00
Kent Beck
dc618ab122
Encapsulate SceneHistory. A little. (#1016) 2020-03-20 18:45:30 +01:00
David Luzar
fda06e4fc3
Fix history - the 2nd installment (#1014)
* don't regenerate versionNonce on pushEntry

* fix history handling around multi-point arrows

* remove filtering from getElementMap helper
2020-03-19 11:41:32 -07:00
David Luzar
82ce068972
fix history (#1009)
* fix history

* tweak withBatchedUpdates typing
2020-03-19 14:51:05 +01:00
David Luzar
373d16abe6
improve & granularize ExcalidrawElement types (#991)
* improve & granularize ExcalidrawElement types

* fix incorrectly passing type

* fix tests

* fix more tests

* fix unnecessary spreads & refactor

* add comments
2020-03-17 20:55:40 +01:00
Pete Hunt
3f8144ef85
Fix many syncing issues (#952) 2020-03-14 20:46:57 -07:00
Pete Hunt
83a2f5de28
remove closures from mutateElement, get rid of the element spreading (#902) 2020-03-10 20:11:02 -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
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
David Luzar
9439908b92
use a better cloning algorithm (#753)
* use a better cloning algorithm

* Revert "use a better cloning algorithm"

This reverts commit 7279262129d665ffa92f016802155c1db7c35b7f.

* implement custom cloning algorithm

* add tests

* refactor

* don't copy canvas & ignore canvas in related ops

* fix tests
2020-02-19 22:28:11 +01:00
Christopher Chedeau
5256096d76
Fast & Furious (#655)
* [WIP] Fast & Furious

* ensure we translate before scaling

* implement canvas caching for rest of elements

* remove unnecessary ts-ignore

* fix for devicePixelRatio

* initialize missing element props on restore

* factor out canvas padding

* remove unnecessary filtering

* simplify renderElement

* regenerate canvas on prop changes

* revert swapping shape resetting with canvas

* fix blurry rendering

* apply devicePixelRatio when clearing canvas

* improve blurriness; fix arrow canvas offset

* revert canvas clearing changes in anticipation of merge

* normalize scrollX/Y on update

* fix getDerivedStateFromProps

* swap derivedState for type brands

* tweak types

* remove renderScene offsets

* move selection element translations to renderElement

* dry out canvas zoom transformations

* fix padding offset

* Render cached canvas based on the zoom level

Co-authored-by: David Luzar <luzar.david@gmail.com>
Co-authored-by: Preet <833927+pshihn@users.noreply.github.com>
2020-02-19 17:25:01 +01: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
Lipis
ee68af0fd3
Set Trailing Cmma to (#525) 2020-01-24 12:04:54 +02: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
Enzo Ferey
88a9cee8bb History improvements (#337)
* Simplified redoOnce.

* Help mental model.

* Move clear redo stack where it belongs.

* Not needed anymore as we check for same state.
2020-01-12 03:19:24 -08:00
Christopher Chedeau
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
Gasim Gasimzada
74764b06eb Regenerate roughjs shape only when the item is updated (#316)
* 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
Gasim Gasimzada
862231da4f Make all operations on elements array immutable (#283)
* 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
Gasim Gasimzada
829a65b8cb
Refactor Element Functions (#233)
* 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
Gasim Gasimzada
d0365933a9
Extract history (#213)
* Extract History into its own module

* Encapsulate undo and redo actions within history

* Encapsulate clearing redo stack within History

* Add private access modifiers to scene history class member variables

* Remove duplicate files
2020-01-06 21:58:48 +04:00