Commit graph

2294 commits

Author SHA1 Message Date
Lu Wilson
a176522c57
Allow right clicking selection backgrounds (#1968)
This PR fixes not being able to right-click the selection background of
shapes.
* It still lets you right-click outside of a selection to deselect.
* It still lets you right-click a different shape inside the selection
bounds.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Draw a squiggle.
2. Select it.
3. Right-click somewhere inside the selection bounds (but NOT on the
squiggle itself).
4. The context menu should open.

- [ ] Unit Tests
- [ ] End to end tests

### Release Notes

- Improved right click behaviour.

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-09-29 12:31:43 +00:00
Steve Ruiz
230212028f
Mark an undo before toggling lock (#1969)
This PR adds a history mark before toggling locked.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Create a shape.
2. Use the menu or a shortcut to toggle locked.
3. Undo.
4. The locked should undo but the shape should still be there.

### Release Notes

- Mark an undo before toggling locked.
2023-09-29 11:04:06 +00:00
Mitja Bezenšek
56e5bfdd71
Stop editing frame headers when clicking inside a frame. (#1955)
Before (notice how we stay in `editing_shape`:


https://github.com/tldraw/tldraw/assets/2523721/d4553675-8412-41d9-b300-bbe87b719caa

After:



https://github.com/tldraw/tldraw/assets/2523721/e9788b1c-f2d9-473d-ba4c-cec7f822547a

It selects the shape, similar to what we do with geo shapes:



https://github.com/tldraw/tldraw/assets/2523721/a6210577-aec0-4fc0-892a-eedfed6f737b


The only downside is that we also stop editing shape if we click on the
frame header. That said that case is currently a bit broken. We'd
probably want to insert caret at the clicked position (which we
currently don't do).

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Insert a frame.
2. Double click the frame header to edit it.
3. Click inside the frame. 
4. This should now stop editing the header.

- [ ] Unit Tests
- [ ] End to end tests

Closes #1965 

### Release Notes

- Stop editing frame headers when clicking inside of a frame.

---------

Co-authored-by: Lu[ke] Wilson <l2wilson94@gmail.com>
2023-09-29 09:27:45 +00:00
Lu Wilson
8c0e6abbeb
Lokalise: Translations update (#1964)
This pull request was initiated by Lokalise (user Lu) at 2023-09-28
17:27:27

## Release notes

* Updated community translations for German and Galician
2023-09-28 17:52:47 +00:00
Steve Ruiz
fbf9469b46
[improvement] improve arrows (for real) (#1957)
This PR improves handling of edge cases in arrows.
![Kapture 2023-09-27 at 21 59
25](https://github.com/tldraw/tldraw/assets/23072548/ff761ed5-14cd-4a0e-af0b-6490f3198217)
![Kapture 2023-09-27 at 22 09
23](https://github.com/tldraw/tldraw/assets/23072548/42ddaaf5-5b09-466f-a77b-6f3b51af0fb7)


### Change Type

- [x] `patch` — Bug fix

### Test Plan

Make arrows short, overlapping, etc. There should be no "flipped" arrows
or wrong arrows.

- [x] Unit Tests

### Release Notes

- Improve arrows.
2023-09-28 16:13:14 +00:00
David Sheldrick
84788cded6
[infra] missing await (#1951)
follow up to #1950 

### Change Type

- [ ] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [x] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version
2023-09-26 16:44:47 +00:00
David Sheldrick
0556b140de
[infra] maybe fix canary publish (#1950)
This last day or two our npm publish script has been randomly failing
due to npm flakiness. I'm seeing the following error:

Failed to save packument. A common cause is if you try to publish a new
package before the previous package has been fully processed.

This doesn't seem to be our fault since we're publishing things in the
right order, the version numbers and package.json files are all correct,
and we're waiting for things to appear in the registry after publishing
before moving on to the next package.

So I'm thinking maybe npm is a little tired right now or something and
needs a little extra time to handle things.

So I've wrapped our publish command inside a retry block.

At the same time I noticed that the `--tolerate-republish` flag does not
seem to be working for canary version numbers, so I've added some extra
logic for that too. Hopefully this means if things fail due to
persistent npm flake we can just run the action again.

### Change Type

- [ ] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [x] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version
2023-09-26 15:36:32 +00:00
Steve Ruiz
9e4dbd1901
[fix] geo shape text label placement (#1927)
This PR fixes the text label placement for geo shapes. (It also fixes
the way an ellipse renders when set to dash or dotted).

There's still the slightest offset of the text label's outline when you
begin editing. Maybe we should keep the indicator instead?

### Change Type

- [x] `patch` — Bug fix

### Test Plan

Create a hexagon shape
hit enter to type
indicator is offset, text label is no longer offset

---------

Co-authored-by: David Sheldrick <d.j.sheldrick@gmail.com>
2023-09-26 14:05:05 +00:00
alex
398bd352ae
fix clipping on nested non-intersecting frames (#1934)
Previously, if a shape had two frame parents and those frames didn't
intersect, we'd render the shape without any clipping. This is because
in the case that we don't find an intersection we were returning
undefined (meaning nothing is masked out) instead of an empty array
(meaning everything is masked out)

![Kapture 2023-09-19 at 16 34
08](https://github.com/tldraw/tldraw/assets/1489520/3192c3df-5a71-4dea-a720-6319a803cd1c)

Fixes #1933 

### Change Type

- [x] `patch` — Bug fix


### Test Plan

1. create a frame (A)
2. create a shape (B) to the left of frame A
3. create a frame (C) with another shape (D) inside to the left of shape
B
4. select shape B and frame C
5. drag shape B into frame A
6. make sure both frame C and shape D are completely clipped
2023-09-26 12:58:39 +00:00
alex
79f46da199
expanded highlighter geometry (#1929)
Currently, the highlighter shape uses a single 0-width line for its
geometry, same as the draw tool. For the draw tool this works ok - the
visual line is thin enough that unless you zoom right in, it's hard to
find areas where the hover should trigger but isn't. As the highlighter
tool is much thicker though, it's relatively easy to find those areas.

The fix is for the geometry to represent the line including its thick
stroke, instead of at 0-width. There are two possible approaches here:
1. Update the polyline geometry to allow passing a stroke width.
2. Instead of a polyline, make the highlighter shape be a polygon that
traces _around_ the stroke

1 is the more accurate approach, but is hard to fit into our geometry
system. Our geometry is based around two primitives: `getVertices` which
returns an array of points around the shape, and `nearestPoint` which
returns the nearest point on the geometry to a vector we pass in. We can
account for a stroke in `nearestPoint` pretty easily, including it in
`getVertices` is hard - we'd have to expand the vertices and handle line
join/caps etc. Just making the change in `nearestPoint` does fix the
issue here, but i'm not sure about the knock-on effect elsewhere and
don't really want to introduce 1-off hacks into the core geometry
system.

2 actually means addressing the same hard problem around outlining
strokes as 1, but it lets us do it in a more tightly-scoped one-off
change just to the highlighter shape, instead of trying to come up with
a generic solution for the whole geometry system. This is the approach
I've taken in this diff. We outline the stroke using perfect-freehand,
which works pretty well but produces inaccurate results at edge-cases,
particularly when a line rapidly changes direction:

![Kapture 2023-09-19 at 13 45
01](https://github.com/tldraw/tldraw/assets/1489520/1593ac5c-e7db-4360-b97d-ba66cdfb5498)

I think that given this is scoped to just the highlighter shape and is
imo an improvement over the stroke issue from before, it's a reasonable
solution for now. If we want to in the future we could implement real
non-freehand-based outlining.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Create a highlight shape
2. Zoom in
3. Make sure you can interact with the shape at its edges instead of
right in the center
2023-09-26 11:21:37 +00:00
Steve Ruiz
5cd74f4bd6
[feature] Include sources in TLExternalContent (#1925)
This PR adds the source items from a paste event to the data shared with
external content handlers. This allows developers to customize the way
certain content is handled.

For example, pasting text sometimes incudes additional clipboard items,
such as the HTML representation of that text. We wouldn't want to create
two shapes—one for the text and one for the HTML—so we still treat this
as a single text paste. The `registerExternalContentHandler` API allows
a developer to change how that text is handled, and the new `sources`
API will now allow the developer to take into consideration all of the
items that were on the clipboard.
 
![Kapture 2023-09-19 at 12 25
52](https://github.com/tldraw/tldraw/assets/23072548/fa976320-cfec-4921-b481-10cae0d4043e)

### Change Type

- [x] `minor` — New feature

### Test Plan

1. Try the external content source example.
2. Paste text that includes HTML (e.g. from VS Code)

### Release Notes

- [editor / tldraw] add `sources` to `TLExternalContent`
2023-09-19 15:33:54 +00:00
Steve Ruiz
b6ebe1e274
[improvement] quick actions (#1922)
This PR:

- improves the quick actions bar, enabling undo / redo actions when the
eraser is selected.
- for actions that effect selected shapes, calling the action when the
select tool is not selected will select the select tool and run the
action
- actions that effect selected shapes are hidden from the menu when the
select tool is not selected

### Change Type

- [x] `major`

### Test Plan

1. Select the eraser tool, the undo / redo buttons should still be
there.

1. Select two shapes
2. Select the draw tool
3. The menu should not display most options, e.g. cut or paste, but
should display undo / redo
4. Press Shift+H
5. The shapes should not move, but the select tool should be selected
again

### Release Notes

- Improve the menu / kbds behavior when select tool is not active
2023-09-19 15:33:39 +00:00
David Sheldrick
386a2396d1
Fix shape drag perf (#1932)
This prevents geometry from being recalculated when dragging shapes
around. It uses an equality check on the shape props to opt out of
recalculations. This still allows bounds to be calculated based on other
reactive values, so if folks really want to use x,y values or opacity or
whatever, they can call editor.getShape(id) when making their
calculation.

### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version


### Release Notes

- Fixes a perf regression for dragging shapes around
2023-09-19 15:29:13 +00:00
Lu Wilson
db58d9c54f
Firefox: Fix dropdowns not opening with touch (#1923)
Fixes #1921

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. On firefox...
2. Use a touch device (or devtools)...
3. Try to open a dropdown menu, eg: main menu, styles menu, more tools
menu.
4. Make sure the menu opens correctly.

- [ ] Unit Tests
- [ ] End to end tests

### Release Notes

- Firefox: Fixed dropdown menus not opening with touch.
2023-09-19 14:58:10 +00:00
David Sheldrick
0e621e3de1
Use smarter rounding for shape container div width/height (#1930)
This is a follow up to #1915 which caused the shape container div
dimensions to be wildly inaccurate. We thought it wouldn't matter but we
had a note on discord from someone who was relying on the div container
being accurate.

This rounds the shape dimensions to the nearest integer that is
compatible with the user's device pixel ratio, using the method
pioneered in #1858 (thanks @BrianHung)

### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version


### Release Notes

- Improves the precision of the shape dimensions rounding logic
2023-09-19 13:14:51 +00:00
Lu Wilson
5dc1436d80
Fix lines being draggable via their background (#1920)
Fixes #1914 

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Draw a line shape at a 45 degree angle.
2. Select the line.
3. Click and drag the empty space next to the line.
4. It should select the canvas.

- [x] Unit Tests
- [ ] End to end tests

### Release Notes

- None - unreleased bug
2023-09-19 12:16:38 +00:00
Lu Wilson
52a838f3ff
Fix first handle of line snapping to itself (#1912)
This PR stops the first handle of a line snapping to itself.

This is an extra fix that I noticed while testing #1910
![2023-09-18 at 16 00 56 - Maroon
Crab](https://github.com/tldraw/tldraw/assets/15892272/f09e18f7-efdd-4b6d-acaf-272f44b98644)


### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Draw a line.
2. Switch to the select tool.
3. Create another segment in the line by dragging out its 'middle'
handle.
4. Move the **first** handle of the line.
5. ... while holding ctrl/cmd.
6. Make sure the handle doesn't try to snap to itself.

- [ ] Unit Tests
- [ ] End to end tests

### Release Notes

- Fixed a bug where the first handle of a line shape could snap to
itself.
2023-09-19 12:16:22 +00:00
Takuto Mori Gump
f510dc2452
[fix] Moving group items inside of a frame (dropping) (#1886)
closes: #1884 

Fix bug: ungroup when moving a shape in a group in a frame.

### before 


https://github.com/tldraw/tldraw/assets/24749358/994a871a-5da2-4d8b-b80e-a4db43e66142


### after

https://github.com/tldraw/tldraw/assets/24749358/4395d416-b7f6-4af0-a4c2-0bf77c29d7e2



### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: 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
- [ ] End to end tests

### Release Notes

- Fix bug: ungroup when moving a shape in a group in a frame.

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
Co-authored-by: David Sheldrick <d.j.sheldrick@gmail.com>
2023-09-19 13:14:04 +01:00
Hana
b22c68be54
[fix] id properties of undefined (#1730) (#1919)
This PR fixes id properties of undefined.

```js
PageMenu.mjs:89 Uncaught TypeError: Cannot read properties of undefined (reading 'id')
    at PageMenu2 (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/@tldraw+tldraw@2.0.0-canary.c52ba35ee89f_@types+react-dom@18.2.7_@types+react@18.2.21_react-dom@18.2.0_react@18.2.0/node_modules/@tldraw/tldraw/dist-esm/lib/ui/components/PageMenu/PageMenu.mjs:99:32)
    at renderWithHooks (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/next@13.4.19_@opentelemetry+api@1.4.1_react-dom@18.2.0_react@18.2.0_sass@1.66.1/node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:10697:18)
    at updateFunctionComponent (webpack-internal:///(app-pages-browser)/./node_modules/.pnpm/next@13.4.19_@opentelemetry+api@1.4.1_react-dom@18.2.0_react@18.2.0_sass@1.66.1/node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:15180:20)
```

![스크린샷 2023-09-19 오후 6 06
26](https://github.com/tldraw/tldraw/assets/59823089/8161c599-3554-4671-86fb-cf303bf60311)


### Change Type

- [x] `patch` — Bug fix

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version


### Test Plan
- [x] Use google chrome force reload

![hard-refresh-browser-chrome](https://github.com/tldraw/tldraw/assets/59823089/0d0cf030-92b3-48db-bbef-252fc813ea03)

- [x] 2\~3 Tldraw pages, 2\~3 peers

1. [tldraw-yjs-example](https://github.com/tldraw/tldraw-yjs-example)
quickly reload
2. Apply it to
[tldraw-yjs-example](https://github.com/tldraw/tldraw-yjs-example) and
then quickly reload
3. Compare the two versions

### Release Notes

- Fixed a bug similar #1730
2023-09-19 10:02:01 +00:00
Takuto Mori Gump
cc3bd1d114
♻️ fix: editing is not terminated after the conversion is confirmed. (#1885)
closes: #1883 

Fix bug: editing is not terminated after the conversion is confirmed.

### before 


https://github.com/tldraw/tldraw/assets/24749358/7821a8b1-70a8-448f-802b-2a791c2fe159


### after


https://github.com/tldraw/tldraw/assets/24749358/2104f3bd-75c5-4551-bd41-315957d1a533


### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: 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
- [ ] End to end tests

### Release Notes

-  fix: editing is not terminated after the conversion is confirmed.

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-09-18 16:54:22 +00:00
Lu Wilson
3b3a0b29fe
Update community translations (#1889)
This PR updates some of our community-contributed translations.

## Release notes

- Updated translations for Russian, Ukrainian, and Simplified Chinese
2023-09-18 16:50:43 +00:00
David Sheldrick
1b8c15316a
Fix line wobble (#1915)
Closes #1911 

### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: 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
- [ ] End to end tests

### Release Notes

- Fixes an issue where lines would wobble as you dragged the handles
around
2023-09-18 16:17:49 +00:00
Taha
6b37e9d0f5
Fix selecting one shape from selection group (#1905)
relates [#1906](https://github.com/tldraw/tldraw/issues/1906)

When clicking a shape within a selection group, that shape should be
selected.

### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version

### Test Plan

1. Add two shapes
2. Select both
3. Click on one to select it, it should deselect the other

- [x] Unit Tests
- [ ] End to end tests

### Release Notes

- Fix bug when selecting a single shape from a selection group

Before


https://github.com/tldraw/tldraw/assets/98838967/1412f9c6-d466-42b3-af94-d08cbc1656be

After
![Kapture 2023-09-18 at 14 15
10](https://github.com/tldraw/tldraw/assets/98838967/70a7336d-7905-4b4c-b684-d5d62f2383b3)
2023-09-18 15:03:01 +00:00
Steve Ruiz
7fecf82423
[fix] help menu css (#1888)
This PR fixes the help menu CSS in certain embedded views.

### Change Type

- [x] `patch` — Bug fix
2023-09-18 15:02:38 +00:00
Lu Wilson
f3af81bf34
Fix highlighter dots not being clickable (#1903)
This PR fixes highlighter shapes not having the correct geometry when
they're a dot. It uses the same approach as Draw shapes.

Closes #1901


![image](https://github.com/tldraw/tldraw/assets/15892272/4bd47bc8-6ee4-4ea4-8a07-099c96e325b9)


![2023-09-18 at 13 57 03 - Fuchsia
Cephalopod](https://github.com/tldraw/tldraw/assets/15892272/bf2d28d5-e09e-47f6-b754-969736e0a11a)

### Change Type

- [x] `patch` — Bug fix


[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version

### Test Plan

1. Click with the highlighter tool to draw a single dot.
2. With the select tool, try to click the dot to select it.

You should be able to select the dot by clicking it.

- [x] Unit Tests
- [ ] End to end tests

### Release Notes

- None - unreleased bug
2023-09-18 15:02:03 +00:00
Steve Ruiz
10f6818a79
[fix] right click (#1891)
This PR fixes right clicks.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Right click a shape. The context menu should show information
relevant to the shape.
2. Lock a shape.
3. Right click to get to the unlock from the context menu.
2023-09-18 15:00:38 +00:00
Steve Ruiz
beb9db8eb7
Fix arrow handle snapping, snapping to text labels, selection of text labels (#1910)
This PR:
- adds `canSnap` as a property to handle and ignores snapping when
dragging a handle that does not have `canSnap` set to true. Arrows no
longer snap.
- adds `isLabel` to Geometry2d
- fixes selection on empty text labels
- fixes vertices / snapping for empty text labels

### Change Type

- [x] `minor` — New feature

### Test Plan

- [x] Unit Tests
2023-09-18 14:59:27 +00:00
David Sheldrick
5458362829
Fix video shape controls (#1909)
The video shape was not interactive in it's editing mode, so I just
updated it to have `pointer-events: all` when editing.

closes #1908 

### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: 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
- [ ] End to end tests

### Release Notes

- Fixes pointer events for editing video shapes.
2023-09-18 14:36:48 +00:00
David Sheldrick
d059183586
Fix line handles (#1904)
closes https://github.com/tldraw/brivate/issues/2876

### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: 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
- [ ] End to end tests

### Release Notes

- Fixes an issue where line handles were slightly offset from the
indicator line.
2023-09-18 13:19:36 +00:00
David Sheldrick
d9ce936ed0
Fix pinch start with toolbar open (#1895)
closes #1893 

Normally when you start a pinch it does the following within a few
frames:

- first finger goes down, begins a drawing gesture, adds a mark to the
undo stack
- second finger goes down, cancels the drawing gesture, bails to the
mark

but when the toolbar is open, it follows the same process without adding
a mark to the undo stack, so that when it bails it bails to the previous
mark.

This PR updates the logic to create a mark ID when setting the mark, and
only bail if the mark id was set on enter.

### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: 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
- [ ] End to end tests

### Release Notes

- Fixes a bug that could trigger undo by accident when closing the style
toolbar via a pinch gesture on mobile.
2023-09-18 10:50:15 +00:00
Taha
c52ba35ee8
[wip] Viewport focus of editing shapes (#1873)
When editing shapes the viewport would be reset to the shape whenever it
moved out of camera bounds, it looked kinda janky. We're now going to
let the user scroll away if they'd like.


### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: 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
- [ ] End to end tests

### Release Notes

Removed a feature to reset the viewport back to a shape that is being
edited.

(Before) Don't be held back by the past
![Kapture 2023-09-15 at 10 57
29](https://github.com/tldraw/tldraw/assets/98838967/d8891621-766e-46a2-b1ca-afa968b7f08c)

(After) You are free to find new avenues of exploration
![Kapture 2023-09-15 at 11 02
36](https://github.com/tldraw/tldraw/assets/98838967/82f318ab-944b-41bd-8297-a35467a15987)
2023-09-15 12:51:01 +00:00
Steve Ruiz
20704ea417
[fix] iframe losing focus on pointer down (#1848)
This PR fixes a bug that would cause an interactive iframe (e.g. a
youtube video) to lose its editing state once clicked.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Create an interactive iframe.
2. Begin editing.
3. Click inside of the iframe
2023-09-09 09:41:06 +00:00
Steve Ruiz
48a1bb4d88
Migrate snapshot (#1843)
Add `Store.migrateSnapshot`, another surface API alongside getSnapshot
and loadSnapshot.

### Change Type

- [x] `minor` — New feature

### Release Notes

- [editor] add `Store.migrateSnapshot`
2023-09-08 17:04:53 +00:00
Steve Ruiz
0b3e83be52
Add snapshot prop, examples (#1856)
This PR:
- adds a `snapshot` prop to the <Tldraw> component. It does basically
the same thing as calling `loadSnapshot` after creating the store, but
happens before the editor actually loads.
- adds a largeish example (including a JSON snapshot) to the examples

We have some very complex ways of juggling serialized data between
multiplayer, file formats, and the snapshot APIs. I'd like to see these
simplified, or at least for our documentation to reflect a narrow subset
of all the options available.

The most common questions seem to be:

Q: How do I serialize data?
A: Via the `Editor.getSnapshot()` method

Q: How do I restore serialized data?
A: Via the `Editor.loadSnapshot()` method OR via the `<Tldraw>`
component's `snapshot` prop

The store has an `initialData` constructor prop, however this is quite
complex as the store also requires a schema class instance with which to
migrate the data. In our components (<Tldraw> and <TldrawEditor>) we
were also accepting `initialData`, however we weren't accepting a
schema, and either way I think it's unrealistic to also expect users to
create schemas themselves and pass those in.

AFAIK the `initialData` prop is only used in the file loading, which is
a good example of how complex it looks like to create a schema and
migrate data outside of the components.

### Change Type

- [x] `minor` — New feature
2023-09-08 14:48:55 +00:00
Steve Ruiz
f21eaeb4d8
[fix] zero width / height bounds (#1840)
This PR fixes zero width or height on Geometry2d bounds. It adds the
`zeroFix` helper to the `Box2d` class.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Create a straight line
2. Create a straight arrow that binds to the straight line

- [x] Unit Tests

### Release Notes

- Fix bug with straight lines / arrows
2023-09-08 14:45:30 +00:00
David Sheldrick
9d8a0b0a8d
clamp x-box and check-box lines to stay within box at small scales (#1860)
Closes [#2737](https://github.com/tldraw/brivate/issues/2737)

For the checkbox and x-box the inner lines are inset slightly from the
edges to account for the stroke width. Alas at tiny box sizes (the box
is creates as w:1,h:1 during a drag-to-create interaction) this was
ending up with the insets overflowing such that they left the box on the
other side, creating miscalculations during the initial resizing.

This PR clamps the positions of the x-box and checkbox inner lines so
they don't escape the bounds of the box.

### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: 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
- [ ] End to end tests

### Release Notes

- Fixes a regression introduced by the geometry refactor related to
x-box and checkbox resizing.
2023-09-08 11:37:50 +00:00
Brian Hung
930abaf5d7
avoid pixel rounding / transformation miscalc for overlay items (#1858)
Fixes pixel rounding when calculating css transformations for overlay
items. Also fixes issue where `editor.instanceState.devicePixelRatio`
wasn't properly updating.

TLDR; `width * window.devicePixelRatio` should be integer to avoid
rounding. `--tl-dpr-multiple` is smallest integer to multiply
`window.devicePixelRatio` such that its product is an integer.

#1852 
#1836 
#1834

### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version

### Test Plan

Would need to add a test checking when `window.devicePixelRatio`
changes, that `editor.instanceState.devicePixelRatio` is equal.

---------

Co-authored-by: David Sheldrick <d.j.sheldrick@gmail.com>
2023-09-08 10:47:14 +00:00
David Sheldrick
ac593b2ac2
Fix paste transform (#1859)
This PR fixes a bug where pasted content would be placed incorrectly if
pasted into a parent frame.

Closes #1857 

### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version

### Test Plan

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

- [x] Unit Tests
- [ ] End to end tests

### Release Notes

- Fixes a bug affecting the position of pasted content inside frames.
2023-09-08 08:26:55 +00:00
David Sheldrick
c1f896b042
Fix indicator transform miscalculation (#1852)
Before

![image](https://github.com/tldraw/tldraw/assets/1242537/3bd21dda-2dab-4e1b-8c57-f90799b98f53)


After

![image](https://github.com/tldraw/tldraw/assets/1242537/8e55e154-a4dc-4f46-ac5a-4b322926733b)

follow up to https://github.com/tldraw/tldraw/pull/1836 should fix the
caveat raised by @leolorenzoluis #1834

### Change Type

- [x] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version

### Release Notes

- Fixes indicator transform miscalculation on android and windows
2023-09-07 12:37:22 +00:00
Steve Ruiz
7c208e4225
[fix] pointer events in shapes (#1855)
This PR fixes a bug that would effect pointer events inside of shapes.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Create a frame
2. Try to edit its title by double clicking on it
2023-09-07 11:29:58 +00:00
Steve Ruiz
cf00eade9c
[fix] exit penmode (#1847)
This PR fixes the "Exit Pen Mode" button (see first commit).

There are some other "wrap some stuff in editor.batch" changes in the
"follow up changes" commit.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Use an ipad / pencil to enter pen mode
2. Click the Exit pen mode button
2023-09-07 08:09:09 +00:00
Taha
2e4f1de944
update currentPageShapesSorted reference in docs (#1851)
Updates currentPageShapesSorted reference in docs.

### Change Type

- [ ] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [x] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: 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
- [ ] End to end tests

### Release Notes

- Add a brief release note for your PR here.
2023-09-06 14:08:28 +00:00
Steve Ruiz
046718f241
[fix] overlays stacking (#1849)
This PR fixes a small bug introduced by #1842 where overlays would be
stacked behind shapes.

### Change Type

- [x] `patch` — Bug fix
2023-09-06 13:55:40 +00:00
Steve Ruiz
3bc79260d8
[fix] assets and content handlers (#1846)
This PR fixes a bug where external content handlers etc defined in an
`onMount` were being overwritten by the default external content
handlers.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Try adding images to rooms in our dot com staging environement
(sorry).
2023-09-06 10:07:18 +00:00
Steve Ruiz
227c97a057
[fix] awful rendering issue (#1842)
This PR fixes an extremely performance-crushing bug that was happening
in Safari and Chrome when iframes were present.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Create one hundred shapes
2. Create a gist or maps embed
3. Select all

If the app crashes or the rendering layers list grows to lots and lots
of layers, that's the bug.

### Release Notes

- [fix] iframe rendering issue
2023-09-05 12:41:57 +00:00
Steve Ruiz
e7ad05fbf5
[fix] line tool bug with tool locked (#1841)
This PR fixes a bug where tool lock would cause the line tool to not
work properly.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Turn on tool lock.
2. Draw two line shapes

- [x] Unit Tests
2023-09-05 08:33:56 +00:00
Steve Ruiz
249bacf50b
[fix] svg overlays when browser zoom is not 100% (#1836)
This PR fixes the effect of browser zoom on SVG overlays. I don't know
why this works.

Should fix https://github.com/tldraw/tldraw/issues/1834

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Draw a rectangle.
2. Change your browser's zoom level (note: not tldraw's zoom level, just
your browser's).
3. Select the rectangle.
2023-09-01 13:34:03 +00:00
Steve Ruiz
a3a780414a
[fix] arrows bind to locked shapes (#1833)
This PR fixes a bug where arrows would bind to locked shapes.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

1. Lock a shape.
2. Confirm that an arrow can neither begin bound to the shape
3. Confirm that an arrow cannot bind to the shape

- [ ] Unit Tests
- [ ] End to end tests

---------

Co-authored-by: Mitja Bezenšek <mitja.bezensek@gmail.com>
2023-08-31 08:48:39 +00:00
alex
3bde22a482
Allow setting user as a prop (#1832)
Add `user` as a prop to `TldrawEditor`

### Change Type

- [x] `patch` — Bug fix
2023-08-30 13:26:14 +00:00
Justin Duke
e3b07631ce
Fix broken link in docs (#1830)
Describe what your pull request does. If appropriate, add GIFs or images
showing the before and after.

### Change Type

- [ ] `patch` — Bug fix
- [ ] `minor` — New feature
- [ ] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [x] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-08-28 08:21:13 +00:00