167 Commits

Author SHA1 Message Date
Aakansha Doshi
fa359034c5
scroll the closest element to center (#1670)
Co-authored-by: Sanghyeon Lee <yongdamsh@gmail.com>
2020-05-30 14:02:32 +02:00
David Luzar
63c10743fb
split font into fontSize and fontFamily (#1635) 2020-05-27 15:14:50 +02:00
David Luzar
ce6f2ff88c
cache nonDeleted elements (#1626) 2020-05-22 10:15:16 -07:00
Lipis
c427aa3cce
Prefer arrow functions and callbacks (#1210) 2020-05-20 15:21:37 +02:00
David Luzar
39c56a4c01
implement stroke style (#1571) 2020-05-14 17:04:33 +02:00
Kostas Bariotis
9ec43d2626
Add free draw mode (#1570) 2020-05-12 21:10:11 +02:00
Ed Bentley
5822117e23
Add optional watermark on export (#1365)
* Add optional watermark on export

* Address init PR feedback

* Add SVG export with refactoring

* Update export.ts

* Move addWatermark to appState

* Update snapshots

* Fit watermark in small scene

* Rename watermark things

Co-authored-by: Lipis <lipiridis@gmail.com>
2020-04-19 12:50:23 -07:00
Faustino Kialungila
51ccf61cc6
Bring root fonts back (#1422)
* redirect font loading

* bring preloading back

* change paths

* add css type

* move fonts to root

* correct paths

* remove redirects

* correct ext

* remove fonts from main CSS

* remove unneeded fonts

Co-authored-by: kbariotis <konmpar@gmail.com>
2020-04-13 20:53:07 +01:00
Timur Khazamov
4228c2e094
[POC] use serviceWorker from create-react-app (#1286)
* Service worker with toast notifications

* Update CSP to allow fetches from now.sh

* Fixed clearing timers

* rounded icon for pwa (#1301)

* rounded icon for pwa

* cirle pwa app icon

* fix fonts caching

* fix app

* fix css import

* Updated csp tp inlcude worker-src: self

* add worker CSP rule

* use square icon

Co-authored-by: Timur Khazamov <t1mmaas@skbkontur.ru>
Co-authored-by: Faustino Kialungila <Faustino.kialungila@gmail.com>
Co-authored-by: kbariotis <konmpar@gmail.com>
2020-04-13 16:08:39 +02:00
Preet
57bbc9fe55
Fill a looped curve with the selected background color (#1315) 2020-04-09 11:46:47 +03:00
Pete Hunt
df0613d8ac
Add NonDeleted<ExcalidrawElement> (#1068)
* add NonDeleted

* make test:all script run tests without prompt

* rename helper

* replace with helper

* make element contructors return nonDeleted elements

* cache filtered elements where appliacable for better perf

* rename manager element getter

* remove unnecessary assertion

* fix test

* make element types in resizeElement into nonDeleted

Co-authored-by: dwelle <luzar.david@gmail.com>
2020-04-08 18:49:52 +02:00
Timur Khazamov
ed378170b7
Use woff2 instead ttf (#1307)
* Use woff2 instead ttf

* Update font in svg-exported files to use woff2

Co-authored-by: Timur Khazamov <t1mmaas@skbkontur.ru>
2020-04-07 15:28:44 -07:00
Daishi Kato
c3b83fba38
fix detecting rotated elements with selection (#1273)
* fix #1232

* Update src/element/bounds.ts

* prefer arrow functions

* fix merging

Co-authored-by: Lipis <lipiridis@gmail.com>
2020-04-07 16:04:20 +02:00
Kostas Bariotis
67805bc7a7
Add collaborators names (#1223)
* add random usernames

* add username state

* add username input

* ability to set names

* fix tests

* set username oon mobile

* remove auto generated names

* remove commented code

* always string

* updaate snapshots

* maintain username when clearing canvas

* Update src/renderer/renderScene.ts

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

* add border

* fix styles

Co-authored-by: Pete Hunt <petehunt@users.noreply.github.com>
Co-authored-by: Faustino Kialungila <faustino.kialungila@gmail.com>
Co-authored-by: Lipis <lipiridis@gmail.com>
2020-04-07 14:02:42 +01:00
David Luzar
729aeacc47
prevent pasting svg copied from excalidraw (#1288)
* prevent pasting svg copied from excalidraw

* remove unnecessary template
2020-04-06 23:02:17 +02:00
Roxana Chiorean
d5366db341
Adding ability to copy to clipboard as SVG (#1250) 2020-04-06 02:13:17 +03:00
David Luzar
4dd947b261
fix scrollToCenter when no elements supplied (#1222)
* fix scrollToCenter when no elements supplied

* make getCommonBounds return default values on empty elements
2020-04-04 18:45:14 +02:00
Kostas Bariotis
b97520400a
Broadcast mouse activity (#1175)
* broadcast mouse activity

* move to same MOUSE_LOCATION event

* remove key up handler

* update tests

* Fix border

* refactor

* rename activity to button

Co-authored-by: Panayiotis Lipiridis <lipiridis@gmail.com>
2020-04-04 17:12:19 +02:00
David Luzar
23540eba4c
sync remote selection (#1207)
* sync remote selection

* skip deleted elements

* remove unnecessary condition & change naming
2020-04-04 16:02:16 +02:00
Jed Fox
663526129a
Proper RTL support (#1154)
* Add RTL styles. Most of the work is done by the browser 💖

* Refactor getLanguage

* Additional fixes

* Mirror the mouse pointer icon

* Move the vertical scrollbar to the left on RTL

* Revert "Mirror the mouse pointer icon"

This reverts commit f69b132538038d231b1b1acc0d6f4a28c91130bb.
2020-04-02 12:21:19 -04:00
Christopher Chedeau
24fa657093
Don't reset cache while zooming using a gesture (#1103)
* Don't reset cache while zooming using a gesture

This reuses the cached canvas while the gesture is happening. Once it has stop updating, then recompute the cache with the proper zoom.

This should massively improve performance when panning on big scenes on mobile

Fixes #1056

* update snapshot tests
2020-03-28 16:59:36 -07:00
David Luzar
6fd2a3b2e5
fix z-index action to account for deleted elems and add tests (#1077) 2020-03-26 00:28:50 -07:00
dependabot-preview[bot]
722c498abe
Bump prettier from 1.19.1 to 2.0.1 (#1060)
* Bump prettier from 1.19.1 to 2.0.1

Bumps [prettier](https://github.com/prettier/prettier) from 1.19.1 to 2.0.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/1.19.1...2.0.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Update formatting

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Panayiotis Lipiridis <lipiridis@gmail.com>
2020-03-23 13:05:07 +02:00
Jed Fox
d8bbe536a7
Restyle the mobile UI a bit (#1002)
* Restyle the bottom bar on mobile as an Island

* Shorter label for collaboration button, truncate too-long button labels

* Refactor safe area things to global vars

* Fix scroll bar positioning, don’t block scrollbars with menu island

* Update text
2020-03-18 11:31:40 -04:00
Christopher Chedeau
db1f97f59e
Revert "[RFC] Randomized names next to mouse pointers. (#971)" (#972)
This reverts commit dcb93f75e6b721738fad9d17d9197636fa8643cd.
2020-03-16 00:38:37 -07:00
Pete Hunt
dcb93f75e6
[RFC] Randomized names next to mouse pointers. (#971)
* [WIP] Add names next to pointers

This implements the rendering and messaging across. Still need to do the UI to set the name.

Also, not really sure what's the best place to send the name and store it.

* Add randomized names

Co-authored-by: Christopher Chedeau <vjeux@fb.com>
2020-03-15 18:56:38 -07:00
Christopher Chedeau
2937efacde
Remove last get/setTransform (#964)
My original hack to put the scale when we create the canvas element doesn't make much sense. It should be done when we are rendering the scene. I moved it there in this PR.

The rest was all about forwarding the scale to where it's needed.
2020-03-15 12:25:18 -07:00
Pete Hunt
35ce1729cc
remove most setState({}) (#959) 2020-03-15 10:06:41 -07:00
Pete Hunt
e1e2249f57
Abstract away or eliminate most of the mutation of the Elements array (#955) 2020-03-14 21:48:51 -07:00
Pete Hunt
3f8144ef85
Fix many syncing issues (#952) 2020-03-14 20:46:57 -07:00
Christopher Chedeau
b20d4539c0
Stop using getTransform (#950)
* Stop using getTransform

Fixes #861

The original motivation behind this is to make it work with Firefox. But it also helped make the code more intentional.

Test Plan:
- Create one square, select it, zoom in repeatedly, make sure that it zooms centered in the screen and everything looks good
- Scroll at various zoom levels, things look good
- Export a small scene at 1x and 3x, make sure the background is properly set and look good

* fix selection element
2020-03-14 17:24:28 -07:00
David Luzar
b9c75b5bc4
use deletedIds map to sync deletions (#936)
* use deletedIds map for sync deletions

* refactor how we create data for syncing

* fix comments

* streamline broadcast API

* split broadcast methods
2020-03-14 21:25:07 +01:00
Edwin Lin
0e5c29b3f3
basic Socket.io implementation of collaborative editing (#879)
* Enable collaborative syncing for elements

* Don't fall back to local storage if using a room, as that is confusing

* Use remote socket server

* Send updates to new users when they join

* ~

* add mouse tracking

* enable collaboration, rooms, and mouse tracking

* fix syncing bugs and add a button to start syncing mid session

* enable collaboration, rooms, and mouse tracking

* fix syncing bugs and add a button to start syncing mid session

* Add Live button and app state to support tracking collaborator counts

* Enable collaborative syncing for elements

* add mouse tracking

* enable collaboration, rooms, and mouse tracking

* fix syncing bugs and add a button to start syncing mid session

* fix syncing bugs and add a button to start syncing mid session

* Add Live button and app state to support tracking collaborator counts

* prettier

* Fix bug with remote pointers not changing on scroll

* Enable collaborative syncing for elements

* add mouse tracking

* enable collaboration, rooms, and mouse tracking

* fix syncing bugs and add a button to start syncing mid session

* enable collaboration, rooms, and mouse tracking

* fix syncing bugs and add a button to start syncing mid session

* Add Live button and app state to support tracking collaborator counts

* enable collaboration, rooms, and mouse tracking

* fix syncing bugs and add a button to start syncing mid session

* fix syncing bugs and add a button to start syncing mid session

* Fix bug with remote pointers not changing on scroll

* remove UI for collaboration

* remove link

* clean up lingering unused UI

* set random IV passed per encrypted message, reduce room id length, refactored socket broadcasting API, rename room_id to room, removed throttling of pointer movement

* fix package.json conflict
2020-03-09 08:48:25 -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
lissitz
e920c078b9
Improve scrollbar-mouse interaction (#667)
* fix scrollbar detection on high devicePixelRatio devices

* don't create a new element on pointerdown over a scrollbar

* Return scrollbars from renderScene and use it in isOverScrollBars

* remove unneeded setState

* show default cursor when hovering or dragging a scrollbar

* disable scrollbars when in multielement mode

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-03-01 21:43:35 +01:00
Lipis
0ee33fe341
Change the extension to .excalidraw (#858)
* Change the extension to .excalidra

* Support opening as well

* support .excalidraw extension on canvas  DranAndDrop

Co-authored-by: Faustino Kialungila <Faustino.kialungila@gmail.com>
2020-02-29 18:42:26 +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
Lipis
759df14143
Revert "Use direct URL for the backend (#846)" (#852)
This reverts commit 602f32b7430b7e3870934954da8549f33a31cd86.
2020-02-28 08:39:26 -08:00
Lipis
602f32b743
Use direct URL for the backend (#846) 2020-02-28 13:12:34 +01:00
David Luzar
7e0e885417
ensure restored elements are normalized before filter (#844) 2020-02-27 17:37:43 +01:00
Jed Fox
4e489bfb6d
Fix zoom being set to NaN (#807)
* Fix zoom being set to NaN

* recover zoom default value on restore if invalid

Co-authored-by: David Luzar <luzar.david@gmail.com>
2020-02-22 14:37:04 +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
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
Timur Khazamov
eee961d65f
Use meta key + wheel to zoom in/out (#769) 2020-02-16 14:38:53 +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
Gasim Gasimzada
ad4ad238ef
Remove invisibly small elements on scene load (#754) 2020-02-10 15:38:41 +01:00
Christopher Chedeau
c2a3b67ccc
Fix scrollbar (#735)
The computation was not correct. I'm not really sure how it used to work but it was not taking into account the dimensions of the scene so it was wrong.

The new algorithm is computing the scrollbar such that it's the position of the viewport in relationship to the bounding box of the viewport and all the elements.

Fixes #680
2020-02-08 16:20:14 -08:00