Wykres commitów

1880 Commity (a4fff303bf5c8ba4f63117e58b7f2dfe49a8abf1)

Autor SHA1 Wiadomość Data
Mitja Bezenšek 787eab75d6
Add migration for horizontal alignment (#1443)
This adds a migration to migrate existing alignment options to their
legacy counter parts (`start` -> `start-legacy`, `end` -> `end-legacy`,
`middle` -> `middle-legacy`).

With this change the legacy options don't show any align as active in
the Styles panel:
![CleanShot 2023-05-23 at 19 53
45](https://github.com/tldraw/tldraw/assets/2523721/4017e03a-9492-4a02-b991-ac206f40ae17)

I think this is probably what we want.

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. Use some old preview link to create Geo and Note shapes with old
alignment options. You can use this one:
https://examples-kzwtf68jr-tldraw.vercel.app/
2. Copy and paste these shapes over to staging. Nothing should change
visually.
3. Also try out exporting to svg (with both old and new alignment
options)

- [x] Unit Tests
- [ ] Webdriver tests

### Release Notes

- Add support for legacy alignment options.

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-05-24 11:34:13 +00:00
Lu Wilson 89428edffc
Fix issue template label not getting applied (#1428)
This PR *should* fix our issue templates not working correctly.

Before: No label was getting assigned to feature requests.
After: We add the 'enhancement' label to them.

### Change Type

- [x] `patch` — Bug Fix
2023-05-24 11:31:34 +00:00
alex 0375b5d86d
Stricter ID types (#1439)
We noticed that when inferring the type of a shape from its ID, it was
getting inferred as `any` which was hiding some issues. This diff
switches `BaseRecord`'s automatic ID to an explicit one, which lets us
pass in our correct `TLShapeId` definition and still have it play nicely
with other places.

### Change Type

- [x] `patch` — Bug Fix

### Release Notes

[internal only, covered by #1432 changelog]

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-05-24 11:25:41 +00:00
Steve Ruiz eb26964130
[refactor] restore createTLSchema (#1444)
This PR restores `createTLSchema`. 

It also:
- removes `TldrawEditorConfig.default`
- makes `config` a required property of `<TldrawEditor>`, though it's
created automatically in `<Tldraw>`.
- makes `config` a required property of `App`
- removes `TLShapeType` and replaces the rare usage with
`TLShape["type"]`
- adds `TLDefaultShape` for a union of our default shapes
- makes `TLShape` a union of `TLDefaultShape` and `TLUnknownShape`

### Change Type

- [x] `major` — Breaking Change

### Release Notes

- [editor] Simplifies custom shape definition
- [tldraw] Updates props for <TldrawEditor> component to require a
`TldrawEditorConfig`.
2023-05-24 10:48:31 +00:00
Steve Ruiz f3182c9874
[fix] local e2e script (#1442)
Fix the e2e script local

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)
2023-05-23 15:57:00 +00:00
Lu Wilson 24f97a569f
Fix cursor shadow getting clipped (#1441)
This PR fixes cursor shadow getting clipped in some cases.

Kap doesn't record the error so you'll have to take my word on this one!

### Change Type

- [x] `patch` — Bug Fix

### Release Notes

- Fixed a bug where custom cursors could have their shadow clipped.
2023-05-23 15:12:49 +00:00
Lu Wilson ab0df9118e
Add SVG cursors for all cursor types (#1416)
Fixes #1410 

This PR adds custom SVGs for all cursor types.
This will unblock some upcoming collaboration features!

It also adds some basic debugging for custom cursors.

![2023-05-19 at 11 02 57 - Coffee
Shrimp](https://github.com/tldraw/tldraw/assets/15892272/dbc84d04-604f-43e5-acd2-69df956e5784)

It uses custom cursors for any shape-related UI, like links.

![2023-05-19 at 11 07 04 - Amaranth
Aphid](https://github.com/tldraw/tldraw/assets/15892272/7eb25f6a-0552-47bd-b2b9-f6c3dc2fca70)

But it sticks with the default browser cursors for the non-canvas UI.

![2023-05-23 at 15 06 29 - Apricot
Bovid](https://github.com/tldraw/tldraw/assets/15892272/2fe35afb-095a-4454-a6c3-aa8337b71506)

### Change Type

- [x] `minor`

### Test Plan

1. Enable debug mode.
2. From the debug menu, enable "Debug cursors".
3. Hover the cursor over the shapes that appear.
4. Check that the cursor appears correctly over each one.
5. (Don't forget to turn off "Debug cursors" after use).

### Release Notes

- Added consistent custom cursors.

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-05-23 14:12:11 +00:00
Steve Ruiz abe9237c6e
[refactor] remove `createTLSchema` (#1440)
This PR removes `createTLSchema`, now that the default shapes / utils
are in the editor's `TldrawEditorConfig`. There were a few places that
still called `createTLSchema`, though they would have been missing many
parts of the

### Change Type

- [x] `major` — Breaking Change

### Test Plan

- [x] Unit Tests

### Release Notes

- [tlschema] Removes `createTLSchema` in favor of `TldrawEditorConfig`
2023-05-23 13:35:11 +00:00
Steve Ruiz 649125cdad
[refactor] Remove `TLShapeDef`, `getShapeUtilByType`. (#1432)
This PR removes `TLShapeDef` and associated helpers / references.

It purposely loosens the configuration and typings to better support
customization.

### Change Type

- [x] `major` — Breaking Change

### Test Plan

1. Use the app!

### Release Notes

- [tlschema] Update props of `createTLSchema`
- [editor] Update props of `TldrawEditorConfig`
- [editor] Remove `App.getShapeUtilByType`
- [editor] Update `App.getShapeUtil` to take a type rather than a shape

---------

Co-authored-by: alex <alex@dytry.ch>
2023-05-23 12:32:42 +00:00
Lu Wilson 3ce18c0c31
Fix new wobble (#1431)
This PR stops collaborator cursors wobbling while viewport-following. 
It's a **new wobble** that we haven't seen before! (It crept in at some
point)

It happens when these three things happen at the same time:
* You're following someone
* They're panning
* They're not moving their pointer

eg: This happens when they're trackpad-panning.

So this is *not* the **old wobble** that we fixed before! That one is
still fixed.

---

The **new wobble** looks like this:

![2023-05-22 at 12 08 51 - Magenta
Urial](https://github.com/tldraw/tldraw/assets/15892272/4b738766-cde3-4a9c-9169-76d622bec3bf)

It's sometimes hard-to-spot because of the _smoothing_ that we do.
When we drastically increase the strength of smoothing... the **new
wobble** is less noticeable:
![2023-05-22 at 12 12 40 - Rose
Goat](https://github.com/tldraw/tldraw/assets/15892272/4ece229a-60e8-4923-89f8-4a0f9b702491)

But we can do better!
So for demonstration purposes... let's turn off _smoothing_ to let us
see the **new wobble** more clearly.
![2023-05-22 at 12 16 02 - Gold
Macaw](https://github.com/tldraw/tldraw/assets/15892272/9030cf2a-bdf3-47f0-87f0-a1195ab2fcbf)

Now we can clearly see what's going on...

The cursor is updating every animation **frame**.
The camera is updating every **tick**.

Depending on your screen's refresh rate, these _might be different_!

Let's test that theory by throttling the **tick** further.
As expected, it increases the **new wobble**:
![2023-05-22 at 14 16 21 - Blush
Caterpillar](https://github.com/tldraw/tldraw/assets/15892272/c70ee08c-8fd3-40ae-a4b3-95637c08acc7)

Let's test the theory again by trying on a screen where the _tick_ and
_frame_ are in sync.
As expected, the **new wobble** doesn't happen _most of the time_.

However, _frame_ and _tick_ can still get out of sync! Which causes the
occasional wobble:

![2023-05-22 at 14 38 21 - Lime
Eagle](https://github.com/tldraw/tldraw/assets/15892272/2a9d8c98-194f-4b73-a7ea-ee85ac1fa28f)

So let's fix both cases...
Instead of making the following-camera update every _tick_...
Let's make it update every _frame_!

![2023-05-22 at 15 28 47 - Salmon
Smelt](https://github.com/tldraw/tldraw/assets/15892272/e9f5c10c-d421-4611-b049-7a961218c087)

The perceptive among you might notice a slight wobble that's still
there...
This is an entirely **different wobble** caused by different things.
We can get to it in the future! But we're back at our original
wobble-quota for now.

![2023-05-22 at 14 32 18 - Brown
Tern](https://github.com/tldraw/tldraw/assets/15892272/e1250715-0bf2-4b87-b6e7-a357bccf4106)

When we turn smoothing back on, things look better than before 👍 

![2023-05-22 at 14 42 48 - Cyan
Roundworm](https://github.com/tldraw/tldraw/assets/15892272/f3616c6f-7969-4a8d-80b1-26ee44e6f451)

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. Open a single shared project in two different browser sessions.
2. Make one session's user follow the other.
3. Trackpad-pan the leader's camera around.
4. Check that the wobble has reduced.
2023-05-23 08:04:07 +00:00
Steve Ruiz 53be923921
[refactor] record migrations (#1430)
This PR removes comments from our record types, makes initial version
optional, and unifies the order of initial / current version.

- Initial versions are zero by default
- If no current version is provided to `defineMigrations`, migrations
should be undefined
- Fixes TypeScript quirks in versioning (e.g. only initial version)

This PR also:
- Makes migrations optional when empty
- Removes reference to empty migrations

### Change Type

- [x] `major` — Breaking Change

### Test Plan

- [x] Unit Tests
- [ ] Webdriver tests

### Release Notes

- [tlschema] Improve `defineMigrations`
- [editor] Simplify migration definitions
2023-05-22 21:46:24 +00:00
alex d48e403ed1
Measure individual words instead of just line breaks for text exports (#1397)
This diff fixes a number of issues with text export by completely
overhauling how we approach laying out text in exports.

Currently, we try to carefully replicate in-browser behaviour around
line breaks and whitespace collapsing. We do this using an iterative
algorithm that forces the browser to perform a layout for each word, and
attempting to re-implement how the browser does things like whitespace
collapsing & finding line break opportunities. Lots of export issues
come from the fact that this is almost impossible to do well (short of
sending a complete text layout algorithm & full unicode lookup tables).

Luckily, the browser already has a complete text layout algorithm and
full unicode lookup tables! In the new approach, we ask the browser to
lay the text out once. Then, we use the
[`Range`](https://developer.mozilla.org/en-US/docs/Web/API/Range) API to
loop over every character in the rendered text and measure its position.
These character positions are then grouped into "spans". A span is a
contiguous range of either whitespace or non-whitespace characters,
uninterrupted by any browser-inserting line breaks. When we come to
render the SVG, each span gets its own `<tspan>` element, absolutely
positioned according to where it ended up in the user's browser.

This fixes a bunch of issues:

**Misaligned text due to whitespace collapsing at line breaks**
![Kapture 2023-05-17 at 12 07
30](https://github.com/tldraw/tldraw/assets/1489520/5ab66fe0-6ceb-45bb-8787-90ccb124664a)

**Hyphenated text (or text with non-trivial/whitespace-based breaking
rules like Thai) not splitting correctly**
![Kapture 2023-05-17 at 12 21
40](https://github.com/tldraw/tldraw/assets/1489520/d2d5fd13-3e79-48c4-8e76-ae2c70a6471e)

**Weird alignment issues in note shapes**
![Kapture 2023-05-17 at 12 24
59](https://github.com/tldraw/tldraw/assets/1489520/a0e51d57-7c1c-490e-9952-b92417ffdf9e)

**Frame labels not respecting multiple spaces & not truncating
correctly**
![Kapture 2023-05-17 at 12 27
27](https://github.com/tldraw/tldraw/assets/1489520/39b2f53c-0180-460e-b10a-9fd955a6fa78)

#### Quick note on browser compatibility
This approach works well across all browsers, but in some cases actually
_increases_ x-browser variance. Consider these screenshots of the same
element (original above, export below):

![image](https://github.com/tldraw/tldraw/assets/1489520/5633b041-8cb3-4c92-bef6-4f3c202305de)

Notice how on chrome, the whitespace at the end of each line of
right-aligned text is preserved. On safari, it's collapsed. The safari
option looks better - so our manual line-breaking/white-space-collapsing
algorithm preferred safari's approach. That meant that in-app, this
shape looks very slightly different from browser to browser. But out of
the app, the exports would have been the same (although also note that
hyphenation is broken). Now, because these shapes look different across
browsers, the exports now look different across browsers too. We're
relying on the host-browsers text layout algorithm, which means we'll
faithfully reproduce any quirks/inconsistencies of that algorithm. I
think this is an acceptable tradeoff.

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

* Comprehensive testing of text in exports, paying close attention to
details around white-space, line-breaking and alignment
* Consider setting `tldrawDebugSvg = true`
* Check text shapes, geo shapes with labels, arrow shapes with labels,
note shapes, frame labels
* Check different alignments and fonts (including vertical alignment)

### Release Notes

- Add a brief release note for your PR here.
2023-05-22 15:10:03 +00:00
Steve Ruiz 97ffc168c1
[fix] laser pointer (#1429)
This PR makes two improvements to the laser pointer:
- it increases the opacity of collaborator lasers
- it fixes a case where a scribble could have no points

### Change Type

- [x] `patch` — Bug Fix
2023-05-22 13:11:47 +00:00
Steve Ruiz cbbc0abcc6
[chore] remove yarnrc-private.yml (#1427)
This is a legacy of the chicken run.

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)
2023-05-22 08:56:05 +00:00
Lu Wilson 84e8db6847
Update docs links + guides + build (#1422)
This PR fixes various docs issues.

* Fixes `yarn dev-docs` and `yarn build-docs` not working.
* Updated guides to get assets from the new `tldraw/tldraw` repo instead
of the old `tldraw/tldraw-examples`.
* Updated an old CodeSandbox link to the new StackBlitz. Thanks
@MitjaBezensek for spotting it!

### Change Type

- [x] `documentation` — Changes to the documentation only (will not
publish a new version)

### Release Notes

* [docs] Updated guides to get assets from the new `tldraw/tldraw` repo
instead of the old `tldraw/tldraw-examples`.
* [docs] Updated an old CodeSandbox link to the new StackBlitz.
2023-05-22 08:21:54 +00:00
Steve Ruiz e43b0103fd
Create @tldraw/indices package (#1426)
This PR moves our "fractical indices" library into its own package.

- [x] `major` — Breaking Change

### Release Notes

- [@tldraw/editor] Remove fractional indices code into `@tldraw/indices`
- [@tldraw/indices] Create library for fractional indices code
2023-05-22 08:18:01 +00:00
Steve Ruiz 6ea0cb039f
[feature] Add checkbox to toolbar (#1423)
This PR:
- adds the checkbox to the toolbar
- removes the embed button from the toolbar

### Change Type

- [x] `minor` — New Feature

### Release Notes

- Adds missing checkbox to toolbar.
2023-05-19 13:01:42 +00:00
Mitja Bezenšek 0375dbf8c0
Bump version. (#1421)
Bump vs code version. I build the extension from the
`release-2023-05-16` branch, but didn't push the changes there as we
never pull them back to main. So I'm making this change here.

### Change Type

- [x] `patch` — Bug Fix
2023-05-19 11:43:41 +00:00
Steve Ruiz 2a7b2dcdfd
[improvement] set horizontal position using text alignment (#1419)
This PR makes it so that horizontal alignment in geo and sticky note
shapes also effects the position of the text within the shape.

<img width="1169" alt="image"
src="https://github.com/tldraw/tldraw/assets/23072548/96b28a7d-0f13-46ba-9ea1-82d02b4f870b">

<img width="1274" alt="image"
src="https://github.com/tldraw/tldraw/assets/23072548/fa768c71-4e9e-4cfe-ad8a-94d7700c445d">

This PR also places the shape's label at the center when there is no
text and the shape is not editing.

### Change Type

- [x] `minor` — New Feature

### Test Plan

1. Create shapes with labels
2. Confirm that their labels are positioned correctly
3. Export the shapes and verify the export

### Release Notes

- Geo shapes and sticky notes now position their labels based on their
alignment.
2023-05-19 11:19:11 +00:00
Steve Ruiz 818972f222
[fix] reorder handles in front of selection (#1420)
This PR places handles in front of selection.

<img width="742" alt="image"
src="https://github.com/tldraw/tldraw/assets/23072548/22640acf-54dc-4c69-a041-4187088005b5">

### Change Type

- [x] `patch` — Bug Fix

### Release Notes

- Fix a bug where handles would appear behind selection indicators.
2023-05-19 11:16:03 +00:00
Steve Ruiz 1eb1f89cd1
[feature] add laser pointer (#1412)
This PR adds a laser pointer. It's also available in readonly rooms.

![Kapture 2023-05-18 at 17 00
18](https://github.com/tldraw/tldraw/assets/23072548/4f638dff-8c17-4f9d-8177-4a63a524b7fd)

### Change Type

- [x] `minor` — New Feature

### Test Plan

1. Select the laser pointer tool
2. Draw some lasers.

### Release Notes

- Adds the laser pointer tool.
2023-05-19 11:09:13 +00:00
Lu Wilson 9c28d8a6bd
[firefox] Fix the pointer getting stuck down when you press the control key (#1390)
This PR fixes a bug in firefox where the pointer can get stuck down
while pressing the control key.

It achieves this by taking a previous fix (specifically for
`useShapeEvents`), and it applies the fix at a deeper level (within
`app.dispatch`).

## Before
![2023-05-16 at 15 33 02 - Crimson
Coyote](https://github.com/tldraw/tldraw/assets/15892272/7d4b5bb1-a2e5-400c-9935-fddcc9645e52)

## After
![2023-05-16 at 15 34 03 - Purple
Panda](https://github.com/tldraw/tldraw/assets/15892272/34a598b2-bf6d-4847-8ce9-a3d52c418174)

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. Use firefox.
2. On the canvas... pointer down (to start a selection box).
3. Control key down.
4. Pointer up.
5. Make sure that that the selection box is gone.

^ Repeat the above for:
Pointer down on a shape.
Pointer down on a handle.

### Release Notes

- [Firefox] Fixed a bug where the pointer could get stuck down when the
control key is held down.
2023-05-19 10:35:24 +00:00
Mitja Bezenšek f59bfe01b1
Vertical text alignment for geo shapes (#1414)
Vertical text alignment for geo shapes.

### Change Type

- [x] `minor` — New Feature

### Test Plan

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

- [ ] Unit Tests
- [ ] Webdriver tests

### Release Notes

- This adds vertical text alignment property to geo shapes.

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-05-19 10:23:43 +00:00
David Sheldrick ddca01918f
fix viewport following (#1411)
Forgot to port over my fix for viewport following for the new ephemeral
state stuff.

### 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. Open a multiplayer room in two different browsers
2. Open the people menu and click the follow button next to the other
user's name.
3. pan and zoom in the viewport of the user being followed
4. the other viewport should follow the same movements
2023-05-18 15:19:41 +00:00
Steve Ruiz 2a9ff82a70
[fix] page menu, drag handle css (#1406)
This PR fixes the CSS for the page menu drag handle while editing. It
also makes the page menu participate in the `useMenuIsOpen` API.

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. Select the draw tool
2. Open the page menu
3. Click on the canvas—there should be no dot!
4. Open the page menu
5. Click the edit icon
6. Hover the drag handle; the handle should look correct

### Release Notes

- Fix styling in the page menu
2023-05-18 13:45:19 +00:00
David Sheldrick 6a7dc12162
Switch to new collaborators component (#1405)
Followup to https://github.com/tldraw/brivate/pull/1584

- Removes the old collaborators component, replacing with the new one.
- Removes the associated debug flag

### 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)

### Test Plan

Check that multiplayer presence UI renders correctly

- cursors
- cursor hints (when a peer's cursor goes off the screen)
- selection brush box
- selection/erasing brush
- selected shape(s) outline

### Release Notes

- [Breaking] Removes the old version of LiveCollaborators, replacing it
with the new one based on `TLInstancePresence`
2023-05-18 10:59:46 +00:00
Steve Ruiz a1e72014c6
[improvement] refactor paste to support multi-line text (#1398)
This PR refactors our clipboard handlers. It should simplify the way
that things work and better handle the difference between how the native
API events are handled vs. the browser's clipboard API events.

![Kapture 2023-05-17 at 13 26
34](https://github.com/tldraw/tldraw/assets/23072548/5dedcc25-a1d2-423f-8bc2-415f761b643b)

Everything that used to be supported now also still works.

In addition, we now have several useful features:

### Multiline text can be pasted into the app

When pasting text that contains more than one line, the text is pasted
correctly; even if the clipboard also includes HTML data. Previously, we
would try to paste HTML data if we found it, because that data might
contain tldraw's own content as a comment; but if that failed, we would
paste the data as text instead. This led to pasting text that lost lots
of information from that text, such as line breaks and indentations.

### Multiline text shapes are aligned correctly

When pasting raw text that has more than one line, the text will be left
aligned—or right aligned if the text is likely from a RTL language.

![Kapture 2023-05-17 at 13 42
54](https://github.com/tldraw/tldraw/assets/23072548/f705acd5-136c-4144-80da-6e97ff766a58)

### Common minimum indentation is removed from each line

![Kapture 2023-05-17 at 13 56
28](https://github.com/tldraw/tldraw/assets/23072548/d45c95f6-6d28-4c9f-8cd3-8078700ce928)

This is something that absolutely every app should implement, but here
we go. When multiline text has "common indentation" on each line, which
is often the case when pasting text from code, then that indentation is
removed from each line.

### Auto wrapping for big pastes

When a line has no text breaks but a lot of text, we now set the width
of the text shape.

![Kapture 2023-05-17 at 14 00
04](https://github.com/tldraw/tldraw/assets/23072548/0b7f69c3-bcf9-42e9-a1ed-df026f868793)

## How it works

A `ClipboardThing` is the common interface for things that we found on
the clipboard, native or otherwise. Both `handlePasteFromClipboardApi`
and `handlePasteFromEventClipboardData` parse out `ClipboardThing`s and
pass them to `handleClipboardThings`.

<img width="905" alt="image"
src="https://github.com/tldraw/tldraw/assets/23072548/fd087539-edbb-4527-b5ff-ca7d7c1726b2">

A `ClipboardResult` is the result of processing a `ClipboardThing`, and
usually contains text and other information about that text. We make
decisions on what to create based on which `ClipboardResult`s we find.

When pasting text, we check to see whether the result would be bigger
than the viewport, or if the text is multiline, or if the text is of an
RTL language by testing certain common RTL characters. We make some
adjustments based on those factors, ensuring that the top-left corner of
the text is on screen and reasonably positioned within the viewport if
possible.

### Change Type

- [x] `minor` — New Feature

### Test Plan

1. Copy and paste shapes
2. Copy and paste text from elsewhere into the app
3. Copy and paste images from elsewhere into the app
4. Try on different browsers

### Release Notes

- Improves clipboard logic when pasting text
- Adds support for pasting multi-line text
- Adds maximum widths when pasting single-line text
- Adds support for RTL languages when pasting multi-line or wrapped text
- Strips leading indentation when pasting text
2023-05-17 16:32:25 +00:00
David Sheldrick ad5a23e135
Add stuff for new 'share project' flow (#1403)
Coming up in the ephemeral state branch is the new 'share project' flow
where it uploads the document data before redirecting. This sets up some
stuff that will be needed there.

### 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
- [x] `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)
2023-05-17 16:17:31 +00:00
Steve Ruiz 6573cb2fbe
remove url state, to private (#1402)
This PR moves a hook to the private repo.

### Change Type

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

### Release Notes

- [editor] remove `useUrlState`
2023-05-17 15:43:38 +00:00
Mitja Bezenšek 50bae6d4a1
Don't allow the users to use keyboard shortcuts to select tools in readonly mode. (#1382)
Keyboard shortcuts for selecting tools still worked in readonly mode.
This now disables them - except for select, hand, and zoom tool.

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1.  Create a readonly room.
2. Press keyboard shortcuts for tools and make sure we don't transition
to them (tools toolbar should always show either select or hand tool as
active).
3. Also make sure the keyboard shortcuts still work in non readonly
rooms.

- [ ] Unit Tests
- [ ] Webdriver tests

### Release Notes

- Disable keyboard shortcut events for tools in readonly mode. We only
allow the select, hand tools, and zoom tool.
2023-05-17 15:08:39 +00:00
Steve Ruiz 9101dcfd44
open menus refactor (#1400)
This PR makes a change to how open menus are handled.

### Change Type

- [x] `minor` — New Feature
2023-05-17 14:30:28 +00:00
Steve Ruiz 7131ab597c
Snapshot link menu translations (#1399)
This PR lands a few changes to the UI that are relevant for the Snapshot
link feature (see https://github.com/tldraw/brivate/pull/1824).

### Change Type

- [x] `minor` — New Feature
2023-05-17 14:01:50 +00:00
David Sheldrick a3896fc492
[fix] Don't synchronize isReadOnly (#1396)
We were storing the state of whether or not a document is read-only in
the store. It does not need to be stored there, and it was creating
consistency problems for us, so let's not store it in there.

fixes https://github.com/tldraw/brivate/issues/1864 

### 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)

### Test Plan

1. Create a multiplayer room
2. Create a read-only link for the room
3. Paste the link into a new browser tab (not incognito, needs to have
the same session state)
4. Check the room is read-only in the new tab
5. Check the room is still writable in the previous tab.

### Release Notes

- Removes the isReadOnly value from the `user_document_settings` record
type.
2023-05-17 10:45:43 +00:00
Steve Ruiz 01487be6fa
[fix] example routes on vercel (#1391)
This PR updates our example app's vercel config so that routes (e.g.
bublic.tldraw.com/scroll) will work.

### Change Type
- [x] `internal`
2023-05-16 14:37:40 +00:00
Lu[ke] Wilson d198bb3645
fix pasted tabs not getting converted to space (#1388)
This PR fixes a bug where pasted tabs didn't get converted to spaces.
Fixes #1387

We manually convert tabs to spaces when pressing the tab key. But we
were missing cases where you pasted tabs.

This may or may not be needed with @SomeHats's incoming text change!

<img width="825" alt="Screenshot 2023-05-16 at 12 35 37"
src="https://github.com/tldraw/tldraw/assets/15892272/239771d5-ab65-41e1-9215-60af3fab5c8b">

<img width="763" alt="Screenshot 2023-05-16 at 12 25 03"
src="https://github.com/tldraw/tldraw/assets/15892272/307a6c3a-9f8f-44a8-9e66-a694b92c5067">

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. Copy a tab character: `	`
2. Make a text shape.
3. Paste the tab character.
4. Make sure that it has been converted into 2 spaces.

- [ ] Unit Tests
- [ ] Webdriver tests

### Release Notes

- Fixed a bug where pasted tabs wouldn't get converted into spaces.
2023-05-16 14:35:57 +00:00
Steve Ruiz 0cc95c271d
[fix] overlay rendering issues (#1389)
This PR fixes several issues with the way that SVG overlays were
rendered.
- fixes editing embed shape on firefox (weird SVG pointer events bug)
- fixes layering of overlays
- collaborator cursors are offset

### Change Type

- [x] `patch` — change to unshipped changes

### Test Plan

1. Try editing an embed shape on Firefox
2. Confirm that cursor hints are no longer spinning
3. Confirm that cursors are displayed correctly over other shapes
2023-05-16 14:35:22 +00:00
Mitja Bezenšek 267fea8d5a
Delete an empty text shape when clicking on another text shape. (#1384)
This fixes an issue with empty text shape not being deleted when you
clicked on another text shape. This correctly worked if you clicked on a
shape of a different type or on canvas.

Before:


https://github.com/tldraw/tldraw/assets/2523721/cf79a0a5-c738-49d2-a861-4e23eafc29e5


After:


https://github.com/tldraw/tldraw/assets/2523721/51a31f7e-c0da-45bc-9d04-aa0b0752a459


### Change Type
- [x] `patch` — Bug Fix

### Test Plan

1. Create a text shape and add some text.
2. Double click on the empty canvas, which creates an empty text shape.
3. Click on the first text shape. Confirm that the empty text shape was
deleted and is no longer present.

- [x] Unit Tests
- [ ] Webdriver tests

### Release Notes

- Fix a problem with empty text shapes not getting deleted if you
clicked on another text shape.
2023-05-16 14:33:57 +00:00
Mitja Bezenšek 3e4d9b3fef
Fix setting the grid mode. (#1386)
Fix setting the grid mode. The change was never saved due to the wrong
condition.

Resolves #1385

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. Go to Preferences -> Show grid. 
2. It should allow you to toggle the display of the grid.

- [ ] Unit Tests
- [ ] Webdriver tests

### Release Notes

- Fix grid mode toggle.
2023-05-16 12:10:48 +00:00
Lu[ke] Wilson 03e0cf7f85
Update codesandbox + example link (#1368)
This PR updates the docs site.
* It updates an old CodeSandbox link to the new StackBlitz link.
* It updates an old example link.

There's still more we need to update before closing the tldraw-examples
repo.
I'll add it to the linear project and carry on next week!

### 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
- [ ] `major` — Breaking Change

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

- [x] `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


- [ ] Unit Tests
- [ ] Webdriver tests

### Release Notes

- [docs] Fixed some links to examples.
2023-05-16 09:19:31 +00:00
Lu[ke] Wilson 1bf47391a3
Fix selection foreground being misaligned (#1380)
Nasty one!

This PR fixes the selection foreground of shapes getting misaligned when
the browser zoom was set to something other than 100%. It was always
happening all the time on android.


![image](https://github.com/tldraw/tldraw/assets/15892272/f75c19f9-769b-492c-bacd-fe96c5b596ed)

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. Make a shape.
2. Select it.
3. Change your browser's zoom level.
4. Make sure the selection foreground stay in the right place (eg:
indicator, resize handles).


### Release Notes

- None (fix for a bug that hasn't released)

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-05-16 08:37:37 +00:00
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
alex f1e9981aae main: notify huppy after release 2023-05-15 14:17:19 +01: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
Lu[ke] Wilson bd455b0b8b
Neaten up pr template (#1369)
This PR neatens up our PR template.

Github struggles to render lists with gaps in. Could we make it neater?


![image](https://github.com/tldraw/tldraw/assets/15892272/8dccecc2-48be-419f-9272-ef1e19bd8915)


### 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
- [ ] `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)
- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)

### Release Notes

- None: internal
2023-05-15 08:50:33 +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