Commit graph

1209 commits

Author SHA1 Message Date
alex
cd8c92779d
Expand selection outline for single-selected draw shape (#1379)
Expand the selection outline on draw shapes according to pen thickness
when only one shape is selected.

![Kapture 2023-05-15 at 16 20
01](https://github.com/tldraw/tldraw/assets/1489520/373f0ec1-f43d-46c9-9729-0c84aaf2564b)

Right now the outline of many of our shapes don't take stroke thickness
into account. This is a pretty hard thing to get right, so in the short
term here's a fix for one of the most common places this is an issue:
selecting a single horizontal/vertical draw shape. This fix isn't
perfect: resizing gets slightly janky when you completely flip the shape
- see how the handle leaves the cursor behind in the gif when that
happens. We can revisit with a more comprehensive solution later.

This is pulled out from the highlighter work! The highlighter shape will
use the shape APIs added here.

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. Create a draw shape
2. Select it
3. Selection bounds should include the stroke width
4. Add another shape to the selection
5. Selection bounds should no longer include the stroke width

### Release Notes

- Improve selection outlines around horizontal or vertical draw shapes
2023-05-16 08:35:45 +00:00
Mitja Bezenšek
2c8b431c1f
[fix] Allow interactions with embeds in readonly mode (#1333)
Allow the users to interact with embeds in readonly mode. Not sure if
this should apply to all embeds (cc @orangemug for thoughts on this)?
For example, you can also start editing code sandbox embeds.

One thing that doesn't feel quite right is that readonly mode defaults
to the hand tool, so you always have to switch to select tool to get
this working. I guess moving around is still the more common action
though so 🤷

### Test Plan

1. Create a multiplayer room with some embeds (youtube videos, spotify
playlist).
2. Open the room in readonly mode.
3. Make sure you can interact with embeds. Double click / enter when
selected, you should then be able to play the youtube videos.

- [x] Unit Tests
- [ ] Webdriver tests

### Release Note

- Allow the users to interact with embeds in readonly mode.
2023-05-15 15:37:54 +00:00
Mitja Bezenšek
a824168e0a
Add localizations for snapshots links (#1347)
Add localization key for creating snapshot links.

I guess it's internal?

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)

### Release Notes

- Add localization for creating snapshot links.
2023-05-15 15:30:35 +00:00
Steve Ruiz
72f6b91d2b
[fix] pointer location not updating when moving over editing shape (#1378)
This PR is entirely unrelated to
https://github.com/tldraw/tldraw/pull/1352.

### Change Type

- [x] `minor` — New Feature

### Release Notes

- Fix a bug where the pointer location would not update when moving the
pointer over an editing shape.
2023-05-15 13:30:21 +00:00
Steve Ruiz
5cc04ef2fd
Remove commented code in App (#1377)
This PR removes some commented code from the events PR.

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)
2023-05-15 13:14:18 +00:00
Orange Mug
2d4999322d
Disabling middle click paste in favour of panning (#1335)
Specifically for linux OSes but this isn't a requirement here anywhere
that supports middle click paste will now only pan.

Previously when panning with middle mouse button on linux a paste event
would occur on `pointerup`. This is now fixed.

### Test Plan

1. On linux copy some text to the clipboard
2. Pan with middle mouse button
3. On mouse up there should be no text pasted into tldraw 

### Release Note

- Disabling middle click paste, in favour of panning

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-05-15 13:13:12 +00:00
David Sheldrick
fff9c4c09b
[perf] deleteShapes (#1373)
This PR extracts a static query for the page states that are used when
deleting a shape.

### Change Type

<!-- 💡 Indicate the type of change your pull request is. -->
<!-- 🤷‍♀️ If you're not sure, don't select anything -->
<!-- ✂️ Feel free to delete unselected options -->

<!-- To select one, put an x in the box: [x] -->

- [x] `patch` — Bug Fix

### Release Notes

- Perf improvement for deleting shapes in a document with lots of pages.
2023-05-15 10:02:24 +00:00
David Sheldrick
16b7b07e1a
fix a couple of consistency assumptions (#1365)
This cleans up a couple of assumptions about the state of the world that
break down in multiplayer contexts:

1. updated shapes still exist while redoing
2. redoing the delete of a page that I am on will also redo switching
away from that page


### Change Type

<!-- 💡 Indicate the type of change your pull request is. -->
<!-- 🤷‍♀️ If you're not sure, don't select anything -->
<!-- ✂️ Feel free to delete unselected options -->

<!-- To select one, put an x in the box: [x] -->

- [x] `patch` — Bug Fix
- [ ] `minor` — New Feature
- [ ] `major` — Breaking Change

- [ ] `dependencies` — Dependency Update (publishes a `patch` release,
for devDependencies use `internal`)

- [ ] `documentation` — Changes to the documentation only (will not
publish a new version)
- [ ] `tests` — Changes to any testing-related code only (will not
publish a new version)
- [ ] `internal` — Any other changes that don't affect the published
package (will not publish a new version)



### Release Notes

- Fixes a couple of minor consistency bugs affecting shape updating and
page deletion in multiplayer contexts.
2023-05-12 16:44:10 +00:00
alex
0bd6410d9f
avoid lazy race conditions (#1364)
We had a few issues with lazy race conditions failing CI. This came from
scripts configured to invoke lazy again, rather than through expressing
dependencies between scripts.

This diff reconfigures lazy to articulate these sorts of things as
dependencies instead of through self-invocation. Instead of having lots
of separate `build-package`, `build-docs`, etc commands, we now just
have a build command with package overrides to express more specific
options

### Change Type
- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)

### Release Notes
[internal only]
2023-05-12 15:41:40 +00:00
alex
529574f83a
enable eslint for test files (#1363)
We've had a few issues where .only in tests wasn't getting caught by our
lint rules. Turns out it's because we were excluding tests from eslint
completely

### Change Type
- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)

### Release Notes

internal-only change
2023-05-12 13:19:39 +00:00
David Sheldrick
a48a55d3de
[perf] make ensureStoreIsUsable scale better (#1362)
The new version of the sync engine is gonna be calling
`ensureStoreIsUsable` on every sync message, so I took some time to make
it scale better. At the moment it operates on a serialized version of
the store, which is expensive and unnecessary. Here I changed it to use
reactive queries for the data it needs, so it only operates on small
bits of data and should not become more expensive as the number of
shapes grows.

### Change Type

<!-- 💡 Indicate the type of change your pull request is. -->
<!-- 🤷‍♀️ If you're not sure, don't select anything -->
<!-- ✂️ Feel free to delete unselected options -->

<!-- To select one, put an x in the box: [x] -->

- [x] `patch` — Bug Fix
- [ ] `minor` — New Feature
- [ ] `major` — Breaking Change

- [ ] `dependencies` — Dependency Update (publishes a `patch` release,
for devDependencies use `internal`)

- [ ] `documentation` — Changes to the documentation only (will not
publish a new version)
- [ ] `tests` — Changes to any testing-related code only (will not
publish a new version)
- [ ] `internal` — Any other changes that don't affect the published
package (will not publish a new version)

### Test Plan

1. Add a step-by-step description of how to test your PR here.
2.

- [ ] Unit Tests
- [ ] Webdriver tests

### Release Notes

- Add a brief release note for your PR here.
2023-05-12 11:39:36 +00:00
Steve Ruiz
4e22fa30e1
Export Events stuff (#1360)
This PR exports the `TLUiEventSource` type from ui.

### Change Type

- [x] `patch` — Bug Fix
- [ ] `minor` — New Feature
- [ ] `major` — Breaking Change

### Release Notes

- [ui] export the `TLUiEventSource` type
- [ui] export the `EventsProviderProps ` type
- [ui] export the `useEvents ` hook
2023-05-12 09:45:32 +00:00
David Sheldrick
d76446646c
presence-related fixes (#1361)
This fixes a bug where creating a page would fail if there were multiple
pages with the same index.

This also changes the store to use a throttled version of
requestAnimationFrame. This should be good for relieving backpressure in
situations where the store is updated many times in quick succession. It
also makes testing a lot easier since it has the mocking logic built in.

### Change Type

- [x] `patch` — Bug Fix


### Release Notes

- Fix a bug where creating a page could throw an error in some
multiplayer contexts.
2023-05-12 09:43:51 +00:00
Steve Ruiz
9ccd0f480f
[improvement] rename onEvent to onUiEvent (#1358)
This PR:
- renames `onEvent` to `onUiEvent`
- adds docs for `onUiEvent` to the docs site
- splits the `EventsExample` into `UiEventsExample` and
`StoreEventsExample`

### Change Type

- [x] `major` — Breaking Change

### Release Notes

- [docs] Adds docs for ui events
- [tldraw] Renames `onEvent` to `onUiEvent`
2023-05-12 09:05:56 +00:00
Steve Ruiz
03595bc88d
[improvement] Ui events followup (#1354)
This PR makes several changes to the ui events APIs.

### Change Type

- [ ] `patch` — Bug Fix
- [ ] `minor` — New Feature
- [x] `major` — Breaking Change

### Release Notes

- [ui] Adds source to ui events data object
- [ui] Corrects source for toolbar events
- [ui] Corrects source for clipboard events
- [examples] Updates events example
2023-05-12 08:16:17 +00:00
Steve Ruiz
a722e3e6f0
[fix] various text (#1350)
This PR updates tests for the text shape, as well as updating the logic
of `getTextLines`. We now:

- allow leading whitespace
- allow white space to cause line breaks, trim the whitespace off of the
end of the line. Crazy times!
- fix a bug with geo shapes changes width when growY changes

Note that this is not a "full solution" to line breaks that are caused
by whitespace + wrapping. AFAIK this is impossible to fix in SVG-land
without measuring the SVG element in order to collapse whitespace in the
same way that it collapses in HTML layout.

### Change Type

- [x] `patch` — Bug Fix
- [ ] `minor` — New Feature
- [ ] `major` — Breaking Change

- [ ] `dependencies` — Dependency Update (publishes a `patch` release,
for devDependencies use `internal`)

- [ ] `documentation` — Changes to the documentation only (will not
publish a new version)
- [ ] `tests` — Changes to any testing-related code only (will not
publish a new version)
- [ ] `internal` — Any other changes that don't affect the published
package (will not publish a new version)

### Test Plan

- [x] Webdriver tests

### Release Notes

- Allow leading whitespace
2023-05-11 22:15:24 +00:00
Steve Ruiz
3437ca89d9
[feature] ui events (#1326)
This PR updates the editor events:
- adds types to the events emitted by the app (by `app.emit`)
- removes a few events emitted by the app (e.g. `move-to-page`,
`change-camera`)
- adds `onEvent` prop to the <TldrawUi> / <Tldraw> components
- call the `onEvent` when actions occur or tools are selected
- does some superficial cleanup on editor app APIs

### Release Note

- Fix layout bug in error dialog
- (ui) Add `TLEventMap` for types emitted from editor app
- (editor) Update `crash` event emitted from editor app to include error
- (editor) Update `change-history` event emitted from editor app
- (editor) Remove `change-camera` event from editor app
- (editor) Remove `move-to-page` event from editor app
- (ui) Add `onEvent` prop and events to <Tldraw> / <TldrawUi>
- (editor) Replace `app.openMenus` plain Set with computed value
- (editor) Add `addOpenMenu` method
- (editor) Add `removeOpenMenu` method
- (editor) Add `setFocusMode` method 
- (editor) Add `setToolLocked` method  
- (editor) Add `setSnapMode` method 
- (editor) Add `isSnapMode` method 
- (editor) Update `setGridMode` method return type to editor app
- (editor) Update `setReadOnly` method return type to editor app
- (editor) Update `setPenMode` method return type to editor app
- (editor) Update `selectNone` method return type to editor app
- (editor) Rename `backToContent` to `zoomToContent`
- (editor) Remove `TLReorderOperation` type

---------

Co-authored-by: Orange Mug <orangemug@users.noreply.github.com>
2023-05-11 22:14:58 +00:00
David Sheldrick
5061240912
[chore] Bump nanoid (#1349)
I need to mock nanoid for the ephemeral state fuzz tests, to create
repeatable test runs. In order to do that properly it needs to have a
consistent version among all our packages.

At the same time I'm removing some old unused params in AppOptions

### Change Type

<!-- 💡 Indicate the type of change your pull request is. -->
<!-- 🤷‍♀️ If you're not sure, don't select anything -->
<!-- ✂️ Feel free to delete unselected options -->

<!-- To select one, put an x in the box: [x] -->

- [ ] `patch` — Bug Fix
- [ ] `minor` — New Feature
- [x] `major` — Breaking Change

- [ ] `dependencies` — Dependency Update (publishes a `patch` release,
for devDependencies use `internal`)

- [ ] `documentation` — Changes to the documentation only (will not
publish a new version)
- [ ] `tests` — Changes to any testing-related code only (will not
publish a new version)
- [ ] `internal` — Any other changes that don't affect the published
package (will not publish a new version)


### Release Notes

- Remove unused userId and instanceId props from AppOptions
2023-05-11 11:55:00 +00:00
Steve Ruiz
dfaa536370
[fix] tabs in text exports (#1323)
This PR fixes the appearance of tabs in labels and text when exporting
images.

This involved refactoring our CSS-text-to-multiline-SVG-text.

### Test Plan

1. Create a text or geo shape with a label that includes a tab character
at the beginning of a line (e.g. jsx)
2. Copy the image as SVG and paste

### Release Note

- Fixes a bug with trailing tab characters in text labels on image
export
2023-05-11 09:20:48 +00:00
Orange Mug
88e6f441b1
Fix "copy as png" in firefox when dom.events.asyncClipboard.clipboardItem is enabled (#1342)
Fixes the issue outlined in #1325.

### Test Plan
In firefox

1. Enable clipboard in firefox by going to `about:config` and enabling
`dom.events.asyncClipboard.clipboardItem` (remember to turn it off
afterwards)
2. Test that `copy-as -> PNG` copies the image

In other browsers

1. Test that `copy-as -> PNG` still copies the image

### Release Notes

- Fix "copy as png" in firefox when
`dom.events.asyncClipboard.clipboardItem` is enabled
2023-05-11 06:59:45 +00:00
alex
71aef1764d
Rework the assets package for strategy-specific imports (#1341)
The assets package now only exports esm-formatted .js files. There's one
for each strategy - import-based, and meta.url-based. These are directly
generated as .js and .d.ts files rather than generated as .ts and
converted to js/dts through other means.

As this package depends on esm-specific stuff to function, we don't
publish a cjs version any more.

### Change Type

<!-- 💡 Indicate the type of change your pull request is. -->
<!-- 🤷‍♀️ If you're not sure, don't select anything -->
<!-- ✂️ Feel free to delete unselected options -->

<!-- To select one, put an x in the box: [x] -->

- [ ] `patch` — Bug Fix
- [ ] `minor` — New Feature
- [x] `major` — Breaking Change

- [ ] `dependencies` — Dependency Update (publishes a `patch` release,
for devDependencies use `internal`)

- [ ] `documentation` — Changes to the documentation only (will not
publish a new version)
- [ ] `tests` — Changes to any testing-related code only (will not
publish a new version)
- [ ] `internal` — Any other changes that don't affect the published
package (will not publish a new version)

### Release Notes

- [dev] If you're using the `@tldraw/assets` package, you need to update
your code to `import { getAssetUrlsByImport } from
'@tldraw/assets/imports'` instead of `import { getBundlerAssetUrls }
from '@tldraw/assets`
2023-05-09 16:08:38 +00:00
David Sheldrick
67f5c25c73
[chore] move schema construction to tlschema package (#1334)
Our private tlsync package currently depends on the editor package,
which balloons the size of the cloudflare worker. It also makes it so
that any change to any package triggers a worker refresh, which makes
working on multiplayer stuff kinda miserable.

This is the first PR to fix that problem.

The second PR will need to resolve TLSyncClient's dependency on the
debugFlags somehow. Easiest would be to just remove the offending flag,
but we might want cross-bublic debug flags at some point in the future
so I'll try to find a low-cost way to make that happen while making
`tlsync` not depend on `editor`.

cc @TodePond since you added the flag in question
(`tldrawResetConnectionEveryPing`)

### Release Note

- internal moving stuff around
2023-05-09 14:40:58 +00:00
Steve Ruiz
bb96852b9d
[feature] check-box geo shape (#1330)
This PR adds a `check-box` geo shape. 

![Kapture 2023-05-08 at 15 31
49](https://user-images.githubusercontent.com/23072548/236853749-99ba786f-73a4-4b65-86ca-f2cdac61a903.gif)

It also improves some logic around the `onClick` shape util handler and
some surprisingly related fixes to point hit testing.

### Test Plan

1. Create a geo shape
2. Set it as a checkbox style
3. *easter egg* double click while holding alt to toggle between
check-box and rectangle

- [x] Unit Tests

### Release Note

- Adds checkbox geo shape.
2023-05-09 13:32:04 +00:00
Steve Ruiz
2a36d6342c
[tiny] rename show menu paste (#1332)
This PR renames `showUiPaste` to `showMenuPaste`, since we use
`MENU_PASTE` elsewhere.
2023-05-08 21:06:10 +01:00
Steve Ruiz
15b705800f
[fix] update useTransform.ts (#1327)
This PR fixes the way that rotation is handled in `useTransform`.

Before:
<img width="756" alt="image"
src="https://user-images.githubusercontent.com/23072548/236692574-7fcf94bd-76e2-4584-9ea0-4ea4aa6c7ffc.png">
After:
<img width="738" alt="image"
src="https://user-images.githubusercontent.com/23072548/236692585-f1970c9e-041c-470c-8bdb-af975ef48246.png">

### Test Plan

1. Select a bunch of shapes
2. Rotate the selection
3. The selection box should be correct
2023-05-07 18:24:06 +01:00
Steve Ruiz
aab47a1474
[improvement] dragging start distance on coarse pointer (#1220)
This PR slightly increases the distance needed to initiate a drag when
using a coarse pointer.
2023-05-05 14:48:49 +00:00
Steve Ruiz
f315ea2250
[fix] SVG export for arrows with labels but no arrowheads (#1229)
This PR fixes a bug where arrow shapes without arrowheads would not mask
their labels when exporting images.
2023-05-05 14:17:01 +00:00
Lu[ke] Wilson
dc16ae1b12
remove svg layer, html all the things, rs to tl (#1227)
This PR has been hijacked! 🗑️🦝🦝🦝

The <Canvas> component was previously split into an <SVGLayer> and an
<HTMLLayer>, mainly due to the complexity around translating SVGs.
However, this was done before we learned that SVGs can have overflow:
visible, so it turns out that we don't really need the SVGLayer at all.
This PR now refactors away SVG Layer.

It also updates the class name prefix in editor from `rs-` to `tl-` and
does a few other small changes.

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-05-05 14:14:42 +00:00
Lu[ke] Wilson
b1569c97e0
add docs for TLShapeUtil (#1215)
This PR adds docs for the methods in the TLShapeUtil class.
I think that it's a good page to have docs on, as it shows people what's
possible with the custom shape API.

Currently, our docs are not showing `@param` info for lots of methods,
including the ones added in this PR.
I'll do fix for that in a follow-up PR, so that it's easier to review.

---

Note: Moving forward, we probably want to consider **_where_** these
docs are shown, and how we achieve that.

For example, do we put the docs for these methods in:
* The docs page for the `TLShapeUtil` class?
* The docs pages for the handler types, eg:
[`OnResizeHandler`](http://localhost:3000/gen/editor/OnResizeHandler-type)?
* Both?

Right now, I opted for putting them in the the TLShapeUtil class, as it
keeps them all in one place, and it's what we already do for some
others.

We should consider both - what works best for the docs? and what works
best for code editors?

---

This PR also includes a fix to our pre-commit step that @SomeHats did.
2023-05-05 14:05:25 +00:00
alex
880f82e658
New vite-based examples app (#1226)
Right now this examples app looks exactly the same as our old examples
app, but there are a couple of tiny differences:
- We use `vite` instead of our own esbuild setup for development and
bundling
- We use `@tldraw/assets` for smart asset hashing instead of copying the
assets to a public folder

You can use `@tldraw/assets` with vite with a bunch of extra config, but
it (plus a bunch of other bundlers) also support a special syntax for
specifying asset urls: `new URL('./my/asset.svg',
import.meta.url).href`. This approach is more standards-complient, but
doesn't work with every bundler just yet. This diff also adds a
url-based version of `@tldraw/assets`, although I'd like to tweak the
entry point - right now you need to import from
`@tldraw/assets/lib/urls`, but i'd like to find a way to get this to
`@tldraw/assets/urls` or something at some point.

There are a couple other extra fixes in here:
- vscode builds were broken, they're fixed now!
- there's also a little tweak to the `getBundlerAssetUrls` API to allow
passing in a function instead of an object for URL formatting
- there are new internal-only functions for injecting asset urls
globally instead of passing them in via react props. this means we can
get the benefits of cacheable URLs without having to clutter our
examples by passing them in
2023-05-05 13:10:36 +00:00
Steve Ruiz
0d16942222 readmes 2023-05-04 13:47:56 +01:00
David Sheldrick
b63e871420
[fix] publish (#1222)
- fixes an invalid usage of process.env in the editor package
- fixes some bublic paths in the publishing infra code
2023-05-04 09:25:31 +00:00
David Sheldrick
f44f6e2c9f
[fix] typo in isFocusingInput (#1221)
Fixes
https://discord.com/channels/859816885297741824/1103050527731884082/1103052355110457354
2023-05-03 15:57:59 +00:00
David Sheldrick
00e3d20dc8
[feat] new LiveCollaborators behind feature flag (#1219)
In this PR I'm adding new versions of the `LiveCollaborators` and
`Collaborators` components for the ephemeral state work. They are behind
a feature flag for now.
2023-05-03 13:48:46 +00:00
Steve Ruiz
9fd0803428
[fix] collaborator render order (#1213)
This PR fixes a bug where collaborator cursors would appear below other
overlay content, such as selection boxes.
2023-05-03 08:29:04 +00:00
alex
14b1f24eb2
update @radix-ui/react-popover to 1.0.6-rc.5 (#1206)
Temporarily moving us to a prerelease of this dep. This resolves an
issue where the mobile style menu popover couldn't be closed by tapping
the style button again. See
https://github.com/radix-ui/primitives/issues/2105 for details
2023-05-03 08:28:55 +00:00
David Sheldrick
f5c5b05dc7
[chore] update lazyrepo (#1211) 2023-05-02 12:25:26 +00:00
Steve Ruiz
5ab93eef5f
[fix] pick a better default language (#1201)
This PR improves the language selection. 

Previously, we would miss the user's languages that included a locale.
For example, if a user's languages were `['en-US', 'fr'], then they
would get 'fr' because 'en-US' wasn't in our table—though 'en' was!

We were already doing the splitting elsewhere but now we do it here,
too.

### Release Note

- Improves default language

---------

Co-authored-by: Lu[ke] Wilson <l2wilson94@gmail.com>
2023-04-29 23:06:02 +00:00
Orange Mug
00d4648ef5
Use strokePathData for <ShapeFill/> path to avoid bugs in the inner path algo (#1207)
This avoids some bug with fills in the new inky path algo. This is a
temp fix as it reuses the outer path, but it's fairly broken at the
moment so probably a good hotfix.

Before (notice the background fill busting the bounds of the shape) 

<img width="575" alt="Screenshot 2023-04-27 at 16 54 53"
src="https://user-images.githubusercontent.com/235915/234921462-3f2d81a4-f209-427e-ba33-bfc6b919bba9.png">

After

<img width="575" alt="Screenshot 2023-04-27 at 16 55 24"
src="https://user-images.githubusercontent.com/235915/234921460-7f36ab3e-ec97-4c4a-8634-868bf8eec791.png">

This isn't perfect because we're filling it with this double fill shape,
which I assume has perf issues.

<img width="1058" alt="Screenshot 2023-04-27 at 17 08 28"
src="https://user-images.githubusercontent.com/235915/234921788-f400bac0-fd2c-469a-beec-3e0a0d2f309d.png">

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-04-29 22:58:18 +00:00
Orange Mug
77175a9dc4
Added pHYs to import/export of png images (#1200)
Added the following

 - Always export pngs with a pixel-ratio of `2`
- Added the `pHYs` png metadata chunk describing the pixel ratio so it
opens with the correct size
 - When importing PNGs read the `pHYs` chunk for the sizing info
 
All the exporting is done via just modifying the bytes from the browsers
native image handling.


https://user-images.githubusercontent.com/235915/234309015-19f39f3a-66ce-4ec2-b7d0-b34a07ed346b.mov

I've also added `ANALYZE=true` option to get the build metadata from
esbuild on boot of `yarn dev` which allow me to see the bundle size info
in https://esbuild.github.io/analyze/

![esbuild github
io_analyze_](https://user-images.githubusercontent.com/235915/234310302-c6fe8109-c82d-480a-8c65-c7638b09e71e.png)

You can see that `crc` adds about `4.4kb`

<img width="280" alt="Screenshot 2023-04-25 at 15 33 26"
src="https://user-images.githubusercontent.com/235915/234310669-99e3e787-ddca-4ad2-81cf-b4a541631d62.png">

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-04-29 22:10:01 +00:00
David Sheldrick
731da1bc77
derived presence state (#1204)
This PR adds

- A new `TLInstancePresence` record type, to collect info about the
presence state in a particular instance of the editor. This will
eventually be used to sync presence data instead of sending
instance-only state across the wire.
- **Record Scopes**

`RecordType` now has a `scope` property which can be one of three
things:
- `document`: the record belongs to the document and should be synced
and persisted freely. Currently: `TLDocument`, `TLPage`, `TLShape`, and
`TLAsset`
- `instance`: the record belongs to a single instance of the store and
should not be synced at all. It should not be persisted directly in most
cases, but rather compiled into a kind of 'instance configuration' to
store alongside the local document data so that when reopening the
associated document it can remember some of the previous instance state.
Currently: `TLInstance`, `TLInstancePageState`, `TLCamera`, `TLUser`,
`TLUserDocument`, `TLUserPresence`
- `presence`: the record belongs to a single instance of the store and
should not be persisted, but may be synced using the special presence
sync protocol. Currently just `TLInstancePresence`

This sets us up for the following changes, which are gonna be pretty
high-impact in terms of integrating tldraw into existing systems:

- Removing `instanceId` as a config option. Each instance gets a
randomly generated ID.
- We'd replace it with an `instanceConfig` option that has stuff like
selectedIds, camera positions, and so on. Then it's up to library users
to get and reinstate the instance config at persistence boundaries.
- Removing `userId` as config option, and removing the `TLUser` type
altogether.
- We might need to revisit when doing auth-enabled features like locking
shapes, but I suspect that will be separate.
2023-04-27 18:03:19 +00:00
Orange Mug
da613ea6ef
Fix to not ignore the userId option for <Tldraw/> component in @tldraw/tldraw (#1205)
The `userId` prop in the `<Tldraw/>` component from the `@tldraw/tldraw`
was previously ignored. This PR fixes that to make it operational again.
2023-04-27 10:03:21 +00:00
David Sheldrick
4c65cb8db4
[lite] upgrade lazyrepo (#1198)
* upgrade lazyrepo

* update lockfile + lazy.config
2023-04-25 14:32:17 +01:00
alex
29ed921c67 transfer-out: transfer out 2023-04-25 12:01:25 +01:00
alex
ec84f64e63 lite: delete all 2023-04-21 16:53:31 +01:00
Steve Ruiz
325d494a8a 1.29.2 2023-04-01 07:09:12 +01:00
Steve Ruiz
9967b281be
Update useKeyboardShortcuts.tsx (#1181) 2023-04-01 06:29:06 +01:00
alex
784b4503aa
alex/v2-file-notice: quick note when trying to open a v1 file (#1177) 2023-03-24 14:42:28 +00:00
Mark Eibes
bd124dc308
Update README.md (#1168) 2023-03-23 10:56:30 +00:00
alex
1051f4c28c
Add notice that tldraw will be down for maintenance (#1174)
* alex/offline-notice: offline notice

* alex/offline-notice: cleanup

* update copy

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-03-21 11:45:47 +00:00
Steve Ruiz
ef089bf0f6
Update StyleMenu.tsx (#1172) 2023-03-20 09:33:55 +00:00
Steve Ruiz
fd9200c200 1.29 2023-03-10 11:42:43 +00:00
Steve Ruiz
d0e265fc80
more user select (#1163) 2023-03-10 11:20:10 +00:00
Jang Min
257a7e750c
fix: add PreferencesMenu aria-label (#1131)
* Add aria-label

* Add DMCheckboxItemProps ariaLabel
2023-03-09 19:59:54 +00:00
Jang Min
967efd6b7f
test: aria-label check (#1133)
* Install jest-each

* Add accessibility.spec.tsx

It render App and click button to render context menu.
Then it check if aria-label exists.

* restore lock

* Delete package-lock.json

* Update accessibility.spec.tsx

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-03-09 19:59:31 +00:00
Jang Min
d00c06144d
Remove DropdownMenu.Root modal property (#1132) 2023-03-09 19:42:18 +00:00
Jang Min
80b4f5aedd
fix: copy and paste without selection occurs error (#1135)
* Add optional chaining

* dont allow empty clipboard data

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-03-09 19:41:23 +00:00
Steve Ruiz
a9f1a6ccc7
fix buttons, help button placement (#1145) 2023-02-10 13:51:30 +00:00
Karol Stawowski
b6dacdc1cd
fix: fix copy as png feature (#1143) 2023-02-10 13:42:25 +00:00
Steve Ruiz
3d1d329b6f 1.28.0 2023-02-06 14:26:40 +00:00
Jan Werder
0080a78bcd
Updated German translation (#1140) 2023-02-06 09:31:23 +00:00
Jang Min
d38f5a037b
feat: export menu accessibility (#1121)
* Move export submenu(Edit -> File)

* Add export menu to context menu with no selection

* Add export shortcuts
2023-02-02 16:14:39 +00:00
Jang Min
e02a5cb62e
Remove literals (#1114)
https://tldraw.com -> window.location.origin
2023-02-02 16:11:39 +00:00
Jang Min
34d06b17b3
Add aria-label to undo/redo buttons (#1115) 2023-02-02 16:10:42 +00:00
hiroshisuga
dd5c4ae66e
Update ja.json (#1126) 2023-02-02 16:09:13 +00:00
Mohammad Kazemi
0a6d35e8c2
Update Farsi language translation (#1128)
Added new words and translated them. Also edited and reviewed some of the old translation to make them more consistent.
2023-02-02 16:08:46 +00:00
JuanCasad0
7c688d52e0
Added Galician language + full spanish (#1122)
* Add files via upload

Added Galician translation and Spanish (completed)

* Update translations.ts

Added galician language (gl).

* Fixed identation

* Fixed identation
2023-02-02 16:07:25 +00:00
Simon Riisnæs Dagfinrud
6b7eb77846
Add/fix Norwegian translations (#1127)
* Add `nn-no` translation

* Correct `nb-no` translation

* Add Norwegian translations

* Fix typo
2023-02-02 16:06:41 +00:00
Kevin Park
e2a13d5992
Fix image export bug on multiplayer mode (#1130) 2023-02-02 16:06:09 +00:00
Steve Ruiz
55a8831a6b 1.27.0 2023-01-15 11:22:09 +00:00
KDSBrowne
6f87ff022a
add aria-labels to elements for screen readers (#1106) 2023-01-15 11:16:06 +00:00
Jang Min
60728e069a
fix(tooltip): add tooltips for undo/redo buttons (#1095)
* fix(tooltip): add lack tooltips for undo/redo buttons

* fix: change id of undo/redo buttons
2023-01-15 11:15:32 +00:00
Jang Min
33dde339aa
fix: change StyleMenu id(language-menu -> TD_StyleMenu) (#1102) 2023-01-15 11:14:58 +00:00
yashkumar barot
b5e2f00f6e
[bug] Zoom to 100% translated into Japanese should be 100%にズーム #1058 (#1105) 2023-01-15 11:14:29 +00:00
hiroshisuga
303b60c7e3
Update TldrawApp.ts (#1104) 2023-01-15 11:11:38 +00:00
Daniel Alberski
77943e6f85
fix: updated Polish translations (#1111) 2023-01-15 11:11:04 +00:00
Abedalrahman Shamia
b7d2254298
Add missing Arabic translations (#1113)
* add arabic missing translations

* fix image trans ar
2023-01-15 11:09:50 +00:00
Steve Ruiz
70ca73555b fix tests 2022-12-30 18:05:18 -06:00
Steve Ruiz
4208445a8c 1.26.4 2022-12-30 18:02:02 -06:00
Daniel Molkentin
065c3ddc4a
serve fonts locally via fontsource (#1091)
* [fix] serve fonts locally via fontsource (#1077)

* fix vscode extension build

Co-authored-by: zfgrnzfsberire <noreply@github.com>
2022-12-30 17:56:33 -06:00
Brian Hung
b74a6d71f1
create new ids for new shapes and map old ids to new ids (#1082)
* create new ids for new shapes and map old parent ids to new ids

* duplicate bindings and update shape handles

* spacing

Co-authored-by: Bruno <33330711+bybruno@users.noreply.github.com>

* Update duplicatePage.ts

* Update duplicatePage.ts

Co-authored-by: Bruno <33330711+bybruno@users.noreply.github.com>
Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2022-12-30 17:53:32 -06:00
hiroshisuga
9eb5e56319
Small translation change (#1088) 2022-12-30 16:19:40 -06:00
Cing Sian Dal
cd11fa4892
feat: added Myanmar (Burmese) translation (#1086) 2022-12-30 16:19:19 -06:00
hiroshisuga
ce09e0464a
translation fix (ja) (#1089) 2022-12-30 16:18:50 -06:00
Ahmad Saman
011ccb3052
feat: add kurdish language (#1078)
Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2022-12-16 18:10:39 +00:00
Kevin Park
737168a930
[Tranlation] update ko-kr translation (#1071) 2022-12-16 18:06:28 +00:00
Malte Janßen
b799b51674
Fix spelling mistake in packages/core README (#1070) 2022-12-16 18:06:02 +00:00
Steve Ruiz
24cad6959f 1.7.24 2022-12-03 14:12:31 +00:00
Steve Ruiz
cfa7f6e357
[fix] text export placement (#1066)
* Fix text export placement

* remove console.log

* Update getTextSvgElement.ts
2022-12-03 13:48:56 +00:00
Peng Xiao
8404528aa6
fix: wheel event handled twice issue (#1050) 2022-12-03 13:10:19 +00:00
Ricardo Crespo
d155ac5968
set pointer capture when the pointer is down so it can be checked on pointer move (#1054) 2022-12-03 13:09:41 +00:00
Steve Ruiz
7be4a27d59
add link to new beta (#1065) 2022-12-03 12:26:48 +00:00
Ricardo Crespo
412d4db618
avoid pointerUptime update before calculating isDoubleClick (#1055) 2022-12-03 12:03:22 +00:00
Kishore Chitrapu
73e87d8732
telugu translation files (#1064)
* telugu translation files

* changed language label to Telugu script
2022-12-03 12:02:22 +00:00
Steve Ruiz
c5ff2da775 1.25.2 2022-11-14 15:53:12 +00:00
Steve Ruiz
8feb565794
[fix] types in core (#1044)
* Fix types

* Update README.md
2022-11-14 15:48:56 +00:00
Peng Xiao
8c1195450c
fix: horizontal pan logic (#1040) 2022-11-14 15:43:42 +00:00
Steve Ruiz
0f2abaf286 1.26.1 2022-11-09 16:35:43 +00:00
Steve Ruiz
cde5f711a5
Fix editing blurs (#1037) 2022-11-09 16:32:13 +00:00
Steve Ruiz
6e275f09ef 1.26.0 2022-10-26 14:06:20 +01:00
kazu
6c7ee29625
update cusor component props (#1024)
* update cusor component props

* add metadata property

* add example

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2022-10-26 13:59:12 +01:00
Thai Pangsakulyanont
a85e80961d
Add support for Microsoft Surface Pen eraser (#1009) 2022-10-26 13:55:53 +01:00
Anders Bech Mellson
586c320138
Updated danish translation (#1014) 2022-10-26 13:51:15 +01:00
James Vaughan
7e2395884e
Call onPointerUp on right pointer up (#1008)
* Call onPointerUp on right pointer up

* Set pointer capture on right point events on the canvas
2022-10-26 13:50:58 +01:00
Lucas
6bbff94464
Updated pt-br translation (#1023)
* Update pt-br translation

* Update packages/tldraw/src/translations/pt-br.json

Co-authored-by: Bruno <33330711+bybruno@users.noreply.github.com>

* Update packages/tldraw/src/translations/pt-br.json

Co-authored-by: Bruno <33330711+bybruno@users.noreply.github.com>

* Update packages/tldraw/src/translations/pt-br.json

Co-authored-by: Bruno <33330711+bybruno@users.noreply.github.com>

* Update packages/tldraw/src/translations/pt-br.json

Co-authored-by: Bruno <33330711+bybruno@users.noreply.github.com>

* Update packages/tldraw/src/translations/pt-br.json

Co-authored-by: Bruno <33330711+bybruno@users.noreply.github.com>

* Update packages/tldraw/src/translations/pt-br.json

Co-authored-by: Bruno <33330711+bybruno@users.noreply.github.com>

* Update packages/tldraw/src/translations/pt-br.json

Co-authored-by: Bruno <33330711+bybruno@users.noreply.github.com>

* Update packages/tldraw/src/translations/pt-br.json

Co-authored-by: Bruno <33330711+bybruno@users.noreply.github.com>

* Update packages/tldraw/src/translations/pt-br.json

Co-authored-by: Bruno <33330711+bybruno@users.noreply.github.com>

* Update packages/tldraw/src/translations/pt-br.json

Co-authored-by: Bruno <33330711+bybruno@users.noreply.github.com>

* Update packages/tldraw/src/translations/pt-br.json

Co-authored-by: Bruno <33330711+bybruno@users.noreply.github.com>

* fix: typos, articles and prepositions

Co-authored-by: Bruno <33330711+bybruno@users.noreply.github.com>
2022-10-26 13:50:05 +01:00
Steve Ruiz
0eebdddb5b 1.24.0 2022-10-04 13:08:31 +01:00
James Vaughan
84d78e4d56
Add documentation for the components prop (#1004)
* Add documentation for the components prop

* Add documentation for `hideCursors`
2022-10-04 12:56:54 +01:00
James Vaughan
c5bee7b1be
Call onRightPointCanvas in the canvas onPointerDown handler (#1001) 2022-10-03 11:56:13 +01:00
watchakorn-18k
a7618ff854
Add Thai language (#1002) 2022-10-03 11:55:37 +01:00
Steve Ruiz
e722fcdb4d
Update migrate.ts (#1000) 2022-09-30 15:28:55 +01:00
James Vaughan
d721ae6a2f
Add support for custom cursor components (#994)
* Add support for custom cursor components

* Add tests for the custom cursor props

* Make the main tldraw app take the components prop

* feat: add the ability to hide cursors

* Update cursor props

* Update imports

Co-authored-by: Judicael <46365844+judicaelandria@users.noreply.github.com>
Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2022-09-24 20:24:11 +01:00
Noah Shipley
b7c968e2aa
Feature/nospread use shape tree (#991)
* Improve useShapeTree performance by removing unneeded spread operation

* Update useShapeTree.tsx

Co-authored-by: Noah Shipley <nshipley@centricsoftware.com>
Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2022-09-24 20:04:03 +01:00
Steve Ruiz
6077ebdd90 Update TranslateSession.ts 2022-09-24 18:28:43 +01:00
Judicael
a128b7464a
fix: arrow binding id (#993)
* fix: arrow binding id

* add test for bindingId

* Fix arrows

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2022-09-24 18:27:15 +01:00
Steve Ruiz
31f0f02adf
Update utils.ts (#989) 2022-09-19 16:54:53 +01:00
Alex Kim
0e8e000f79
fix scrolling menus (#977)
* attempt to fix scrolling menus

* add container to keyboard shortuts

Co-authored-by: Judicael <46365844+judicaelandria@users.noreply.github.com>
2022-09-19 09:27:18 +01:00
Alex Kim
8f2dba8311
remove white space in tldr files for prod (#985) 2022-09-19 09:25:35 +01:00
Judicael
4ea39a0263
fix: flipping and resizing arrows (#979)
* fix: flipping horizontal for arrows

* fix: horizontal flip

* fix return

* add test for flipping arrow

* visualize arc points

* adding test for vertically flipping

* remove arc points

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2022-09-13 12:38:42 +01:00
Steve Ruiz
8e55e263bf 1.24.5 2022-09-09 09:54:48 +01:00
Steve Ruiz
254dfdfd77
Fix buttons (again) (#976) 2022-09-09 09:42:46 +01:00
Steve Ruiz
5e24e5a4cb 1.24.4 2022-09-08 13:36:08 +01:00
Steve Ruiz
3ffb9fcfd3 Update KeyboardShortcutDialog.tsx 2022-09-08 13:33:47 +01:00
Steve Ruiz
5fea5b4c69
fix (#968) 2022-09-08 13:33:04 +01:00
Steve Ruiz
0549660244 1.24.3 2022-09-08 11:33:57 +01:00
Steve Ruiz
00e17b65f3 hot fix 2022-09-08 11:13:29 +01:00
Steve Ruiz
b56a3a6982 1.24.1 2022-09-08 10:58:42 +01:00
Steve Ruiz
7774d00e74
[fix] Buttons (#964)
* fix buttons

* update dependencies
2022-09-08 10:45:08 +01:00
Steve Ruiz
760f6494e3 1.24.0 2022-09-08 09:48:50 +01:00
Steve Ruiz
d0cd924ca7
[chore] remove mobx (#961)
* remove mobx as dependency

* fix bugs
2022-09-08 09:38:28 +01:00
Steve Ruiz
c3ff5a51bf Update useCursor.ts 2022-09-07 16:56:29 +01:00
Steve Ruiz
34ce1ed68c 1.22.0 2022-09-07 15:25:47 +01:00
Judicael
ef613af788
fix: include assets when importing document (package tldraw) (#950)
* fix: include asset when importing document

* defensive tweak

* fixey back

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2022-09-07 15:08:32 +01:00
Judicael
e1689d678e
feat: change cursor when panning (#939)
* feat: change icon when panning

* add support for panning with the middle mouse

* Remove state at top tldraw

* logic tweaks

* accept middle clicks on objects

* Update useCursor.ts

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2022-09-07 14:58:32 +01:00
Anders Rex
bb9e7ee47c
Use id as assetId (#949) 2022-09-07 14:09:18 +01:00
Alex Kim
55ea729e3e
fix and complete russian traslation (#948) 2022-09-07 14:06:04 +01:00
Steve Ruiz
ca91e56b29
[improvement] faster svg paths (#959)
* improve svg paths

* split methods add tldraw 1.2.0
2022-09-07 14:05:30 +01:00
Judicael
3957282515
fix: fix text align in a shape on export (#952)
* fix: fix text align in a shape on export

* remove unused import

* fix text alignment
2022-09-07 13:47:34 +01:00
Alex Kim
b327f62bbe
prevent pasting while panning with the middle mouse button on linux (#953) 2022-09-07 13:07:51 +01:00
turkerdev
590aef15ec
Fix reversed zoom in and zoom out (#956)
Fixes #954
2022-09-07 13:07:07 +01:00
Judicael
1130525fdf
fix: draw and eraser direction when holding shift (#958) 2022-09-07 13:06:33 +01:00
Steve Ruiz
9dab372b81 1.22.1 2022-09-01 17:24:33 +01:00
Steve Ruiz
3cfae6278c
Remove share menu (#946)
* Remove share menu

* Delete ShareMenu.tsx

* Remove alert, etc
2022-09-01 16:19:22 +01:00
David Sheldrick
8351936321
Merge pull request #944 from judicaelandria/fix/url
fix: use location origin
2022-09-01 11:45:42 +01:00
David Sheldrick
759407e40c
Merge pull request #940 from judicaelandria/feat/save-project-as-support
feat: save project as (support for firefox and safari)
2022-09-01 11:23:43 +01:00
Judicael
f55a73f827 fix: use location origin 2022-09-01 12:45:17 +03:00
Steve Ruiz
f98310e5bf 1.22.0 2022-09-01 10:13:32 +01:00
Judicael
d816c4567f
Merge branch 'main' into feat/save-project-as-support 2022-09-01 11:18:20 +03:00
David Sheldrick
1be09d2204
Merge pull request #917 from judicaelandria/feat/share-via-link
feat: share via URL
2022-09-01 09:16:54 +01:00
Judicael
f03a79c5a9 add default value to file name, extension file 2022-08-30 17:06:29 +03:00
Judicael
e29e2e5924 generate new snapshot 2022-08-30 16:22:04 +03:00