Commit graph

1972 commits

Author SHA1 Message Date
Lu Wilson
3e2f2e0884
Add tsdocs to Editor methods (#1581)
This PR does a first-pass of adding tsdocs to the methods of the Editor
class.
It's a minimal start — just descriptions of them, and their parameters.
It makes the Editor docs page a lot more fleshed out though, and easier
to quickly scan.
There's still a lot more to do!

### Change Type

- [x] `documentation` — Changes to the documentation only[^2]

### Release Notes

- [dev] Added initial documentation for the Editor class.

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-06-14 06:40:10 +00:00
Steve Ruiz
014576ba87
add presence to yjs example (#1582)
This PR adds presence to the yjs example.

![Kapture 2023-06-13 at 19 47
16](https://github.com/tldraw/tldraw/assets/23072548/759e0bf9-a934-47c7-979f-512c16b03e48)


### Change Type

- [x] `documentation` — Changes to the documentation only[^2]

### Release Notes

- [editor] Add presence to yjs example.
2023-06-13 21:00:53 +01:00
Steve Ruiz
ce1cf82029
Add optional generic to updateShapes / createShapes (#1579)
This PR adds a generic that we can use with `updateShapes` and
`createShapes` in order to type the partials being passed into those
methods. By default, the partials are typed as `TLUnknownShape`, which
accepts any props.

### Change Type

- [x] `minor` — New feature

### Test Plan

- [x] Unit Tests

### Release Notes

- [editor] adds an optional shape generic to `updateShapes` and
`createShapes`
2023-06-13 18:02:17 +00:00
Shahriar Shojib
69e5b248ca
fix: properly remove awareness from store (#1565)
Describe what your pull request does. If appropriate, add GIFs or images
showing the before and after.

### Change Type
This pr updates yjs example to remove awareness when a peer disconnects

<!-- 💡 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

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.

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-06-13 17:05:28 +00:00
Mohammad Kazemi
7a78d14346
Fa translation (#1500)
Update Farsi (Persian) translations.

Note: I used my personal Weblate to manage translations. But the output
file json order of strings is different with the main.json file. I don't
know if it matters.

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-06-13 15:29:48 +00:00
Steve Ruiz
e3b00e7c11
[fix] embeds (#1578)
This PR fixes embeds to remove the `doesResize` prop when creating
embeds / converting between bookmarks and embeds.

### 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. Create an embed
2. Convert between bookmark and embed
2023-06-13 12:45:43 +00:00
Steve Ruiz
b65aef5cf2
[improvement] Embed shape cleanup (#1569)
This PR does some cleanup around our Embed Shape.

It:
- removes used `doesResize` and `overridePermissions` props
- removes the no-longer-needed `tmpOldUrl` prop
- adds a `canUnmount` property to embed definitions, so that some embeds
can unmount when desired

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. Create embed shapes
2. Migrate old data that includes embed shapes?

- [x] Unit Tests

### Release Notes

- [editor] Remove unused props for `TLEditorShape`
- [editor] Adds `canUnmount` property to embed definitions
2023-06-13 08:27:54 +00:00
Mitja Bezenšek
439a2ed3bc
Move the loading of assets to the TldrawEditorWithReadyStore so that all code paths load the assets. (#1561)
Move the preloading of assets to `TldrawEditorWithReadyStore` which
makes it sure that all codepaths preload assets. Before that didn't
happen for cases where we passed in an existing store - snapshots.


### Change Type

- [x] `patch` — Bug Fix

### Release notes
- Fix a problem where assets were not loading in some cases (snapshots).
2023-06-13 08:22:38 +00:00
Steve Ruiz
34a880dcbd
[improvement] bookmark shape logic (#1568)
This PR extracts some logic from the EditUrlDialog into the bookmark
shape util, removing the dependency between the two.

### Change Type

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

### Test Plan

1. Create a bookmark shape
2. Set its URL to an empty string

- [x] Unit Tests
2023-06-12 19:15:58 +00:00
Mitja Bezenšek
edd393353e
Add anchor targets to our headings. (#1571)
Add anchor target for our headings. Makes it much easier to share a link
to a specific part of the page.

### Change Type

- [x] `documentation` — Changes to the documentation only

### Test Plan

1. Open the docs page.
2. The headings should now be anchors to this part of the page.

### Release Notes

- Improve documentation to include anchor targets.
2023-06-12 17:09:17 +00:00
alex
7b03ef9d0c
shapes folder, move tools into shape defs (#1574)
This diff adds a new property to `defineShape`: `tool`.

The tool prop allows shapes to bring a tool along with them as part of
their definition. E.g. the draw shape isn't much use without the draw
tool, so adding the draw shape to your app gives you the draw tool tool.

As part of this, i renamed the `shapeutils` folder to just `shapes`, and
moved a bunch of shape-specific tools from the tools folder into the
shapes folder. This more closely reflects how things will be once we
move our default shapes out of core for tldraw-zero.

### Change Type

- [x] `patch` — Bug fix

### Test Plan

Tested locally

### Release Notes

n/a
2023-06-12 15:39:50 +00:00
Brian Hung
8d409462c0
offset drop point by editor client rect (#1564)
In my app, I have a sidebar and noticed that dropped shapes were being
created at an offset by the sidebar's width. This is because the current
point given to `putExternalContent` does not offset by the editor's
client rect.
2023-06-12 15:23:15 +00:00
alex
1927f88041
mini defineShape API (#1563)
Based on #1549, but with a lot of code-structure related changes backed
out. Shape schemas are still defined in tlschemas with this diff.

Couple differences between this and #1549:
- This tightens up the relationship between store schemas and editor
schemas a bit
- Reduces the number of places we need to remember to include core
shapes
- Only `<TLdrawEditor />` sets default shapes by default. If you're
doing something funky with lower-level APIs, you need to specify
`defaultShapes` manually
- Replaces `validator` with `props` for shapes

### Change Type

- [x] `major` — Breaking Change

### Test Plan

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

- [x] Unit Tests
- [ ] Webdriver tests

### Release Notes

[dev-facing, notes to come]
2023-06-12 14:04:14 +00:00
Lu Wilson
4b680d9451
Lokalise: Translations update (#1572)
This PR is my weekly update from Lokalise.

## Release Notes

- Added and updates translations for Italian, Russian, and Ukrainian.
2023-06-12 12:29:07 +00:00
Steve Ruiz
8d39750787
Update pr template (#1570)
Update PR template

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)
2023-06-12 11:23:35 +00:00
David
65f2727bb7
Fix README typo (#1451)
This PR fixes a slight typo in the README, changing `inifinite` to
`infinite` in line 14.

### 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] `documentation` — Changes to the documentation only (will not
publish a new version)

### Release Notes

- None

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-06-09 14:01:10 +00:00
Judicael
d6be4bf26a
use the right TLEventHandlers (#1486)
### Change Type

Change the `TLEventHandlers` of `onPointerLeave` to use `onPointerLeave`

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

### Test Plan

I don't think we need to test something here because it's just a small
change that doesn't affect anything; just a type IMO

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2023-06-09 13:57:31 +00:00
Steve Ruiz
d71d15124c
yjs example (#1560)
This PR adds a yjs example to the examples app.

### Change Type

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

### Release Notes

- [editor] Adds yjs example project
2023-06-09 12:15:06 +00:00
Mitja Bezenšek
bacb307bad
Asset improvements (#1557)
This PR does the following:
- Add `selfHosted.js`, which is a great option for users that wish to
self host the assets. Works well for both self hosting from the public
folder or via a CDN.
- Updates the docs for assets. We now have a dedicated page for assets
where all the options are more clearly explained. I also removed the
assets explanation from the main docs as the unpkg option should work
out of the box and setting up the assets is no longer necessary.
- Cleaned up the `refresh-assets` script. We now use common `types.d.ts`
file to define our types. All the other options then reuse them.
- Pulled out the `formatAssetUrl` into it's own file. It's now static an
no longer generated.
- `urls.d.ts`, `import.d.ts`, and newly added `selfhosted.d.ts` are now
also no longer generated as we can import the types from `types.d.ts`.
- You can now pass a subset of `assetUrls` to `<Tldraw />` and it will
override the default option with the passed in overrides. This makes it
easy to only customizes certain assets (only change the draw font as an
example).

### Change Type

- [x] `patch` — Bug Fix
2023-06-09 11:43:01 +00:00
David Sheldrick
707ddc876f
More misc sync fixes (#1559)
Follow-up to #1555, taking care of a few more rare edge cases found
during fuzz testing.

### 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
2023-06-09 10:17:14 +00:00
Steve Ruiz
0cc91eec62
ExternalContentManager for handling external content (files, images, etc) (#1550)
This PR improves the editor's APIs around creating assets and files.
This allows end user developers to replace behavior that might occur,
for example, when pasting images or dragging files onto the canvas.

Here, we:
- remove `onCreateAssetFromFile` prop
- remove `onCreateBookmarkFromUrl` prop
- introduce `onEditorReady` prop
- introduce `onEditorWillDispose` prop
- introduce `ExternalContentManager`

The `ExternalContentManager` (ECM) is used in circumstances where we're
turning external content (text, images, urls, etc) into assets or
shapes. It is designed to allow certain methods to be overwritten by
other developers as a kind of weakly supported hack.

For example, when a user drags an image onto the canvas, the event
handler passes a `TLExternalContent` object to the editor's
`putExternalContent` method. This method runs the ECM's handler for this
content type. That handler may in turn run other methods, such as
`createAssetFromFile` or `createShapesForAssets`, which will lead to the
image being created on the canvas.

If a developer wanted to change the way that assets are created from
files, then they could overwrite that method at runtime.

```ts
const handleEditorReady = (editor: Editor) => {
  editor.externalContentManager.createAssetFromFile = myHandler
}

function Example() {
  return <Tldraw onEditorReady={handleEditorReady}/>
}
```

If you wanted to go even deeper, you could override the editor's
`putExternalContent` method.

```ts
const handleEditorReady = (editor: Editor) => {
const handleExternalContent = (info: TLExternalContent): Promise<void> => {
	if (info.type === 'files') {
	   // do something here
	} else {
          // do the normal thing
          editor.externalContentManager.handleContent(info)
        }
}
```

### Change Type

- [x] `major`

### Test Plan

1. Drag images, urls, etc. onto the canvas
2. Use copy and paste for single and multiple files
3. Use bookmark / embed shapes and convert between eachother

### Release Notes

- [editor] add `ExternalContentManager` for plopping content onto the
canvas
- [editor] remove `onCreateAssetFromFile` prop
- [editor] remove `onCreateBookmarkFromUrl` prop
- [editor] introduce `onEditorReady` prop
- [editor] introduce `onEditorWillDispose` prop
- [editor] introduce `ExternalContentManager`
2023-06-08 14:53:11 +00:00
Steve Ruiz
f2e95988e0
Add contributor license agreement. (#1556)
This PR adds a contributor license agreement (CLA) to the project.
Contributors will need to sign the CLA before we merge their PRs. This
will be handled automatically via a bot here on GitHub.

## Context

Did you know tldraw is a [venture
backed](https://tldraw.substack.com/p/tiny-little-seed-round) company?
Our CLA is designed to protect our options for any future re-licensing
of the project's code or transferring ownership, which can become
complicated when taking public contributions community, but which can
become necessary by fate and/or go to market strategies.

A CLA adds a bit of friction and hassle for contributors, however I'd
prefer to be upfront about our relationship rather than doing what many
open source projects have done in the past, which is relicensing code
contributed without such prior agreement.

If you have any questions, feel free to post them below.

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)
2023-06-08 12:45:44 +00:00
David Sheldrick
938bc32259
Misc sync fixes (#1555)
I've been doing some fuzz testing for the socket robustness work. This
PR pulls in the bublic fixes. It also fixes #1511

### 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. Create a frame in a multiplayer room
2. create two boxes inside the frame
3. draw an arrow connecting the two boxes
4. delete the frame
5. hit undo
6. the frame and boxes and arrows should reappear as they were before

### Release Notes

- Fixes a handful of state management bugs that manifest in multiplayer
rooms
2023-06-08 10:16:39 +00:00
Lu Wilson
9d87ee9dd8
[Docs] Change some editor properties to methods (#1553)
This PR changes some App properties into methods, to make them
consistent with everything else.

Closes #1544

Is there any reason why we can't change any of these?

eg:

![image](https://github.com/tldraw/tldraw/assets/15892272/24ef843d-9677-4eca-a756-84fc2188ef17)

### Change Type

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

### Release Notes

- [docs] Fixed some methods that were incorrectly marked as properties.
2023-06-08 10:14:44 +00:00
Lu Wilson
b86c751b03
[Docs] Change some internal methods to public (#1554)
This PR changes some Editor methods from internal to public, so that
they appear on the docs site.

Closes #1545 

### Change Type

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

### Release Notes

- [docs] Changed some Editor methods from internal to public.
2023-06-08 10:09:33 +00:00
Mitja Bezenšek
21cefc77f5
Use unpkg as a default for serving assets. (#1548)
Use unpkg to host our assets and use that as a default. This will smooth
out the first run experience.

The way this works for different use cases:
- It doesn't change the asset loading for VS Code extension and
tldraw.com
- When running our examples (and our local development) [we still
override the
urls](4a9ef5044c/apps/examples/src/index.tsx (L32-L34))
to use the assets from the filesystem. This allows the assets to still
update when you change them.
- When you use our `Tldraw` component and when just copying the examples
code we will now serve the assets from unpkg by default.

I guess it's a breaking change since we will now use unpkg by default.

### Change Type

- [x] `major` — Breaking Change

### Release Notes

- Use unpkg asset hosting as a default.
2023-06-07 21:01:38 +00:00
Steve Ruiz
3eb083cd1a remove e2e files 2023-06-07 08:50:14 +01:00
Steve Ruiz
1531bfa81c
update editor tests (#1547)
This PR renames our test files for tools.

### Change Type

- [x] `tests` — Changes to any testing-related code only (will not
publish a new version)
2023-06-07 07:31:00 +00:00
Mitja Bezenšek
2372478556
Update changelog. Bump version. (#1546)
Update the VS Code changelog and bump the version.

### Change Type

- [x] `patch` — Bug Fix
2023-06-06 16:24:09 +00:00
alex
f2d8fae6ea
hoist opacity out of props (#1526)
This change hoists opacity out of props and changes it to a number
instead of an enum.

The change to a number is to make tldraw more flexible for library
consumers who might want more expressivity with opacity than our 5
possible values allow. the tldraw editor will now happily respect any
opacity between 0 and 1. The limit to our supported values is enforced
only in the UI. I think this is limited enough that it's a reasonable
tradeoff between in-app simplicity and giving external developers the
flexibility they need.

There's a new `opacityForNextShape` property on the instance. This works
exactly the same way as propsForNextShape does, except... it's just for
opacity. With this, there should be no user-facing changes to how
opacity works in tldraw. There are also new `opacity`/`setOpacity` APIs
in the editor that work with it/selections similar to how props do.

@ds300 do you mind reviewing the migrations here?

### Change Type

- [x] `major` — Breaking Change

### Test Plan

- [x] Unit Tests
- [ ] Webdriver tests

### Release Notes

[internal only for now]
2023-06-06 16:15:12 +00:00
Steve Ruiz
355ed1de72
rename app folder to editor (#1528)
Turns out there was one last terrible renaming PR to make. This PR
renames the `@tldraw.editor`'s `app` folder to `editor`. It should not
effect exports but it will be a gnarly diff.

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)
2023-06-06 16:01:54 +00:00
Lu Wilson
5d826c926d
Fix arrows with weird bends crashing (#1540)
This PR prevents a crash when you try to curve an arrow that is pointing
a very small distance.

Fixes #1533

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. Draw a line.
2. Draw an arrow from one point on the line to another point on the
line.
3. It might look weird or flicker (that's ok - that's a *different*
issue - we can fix it another time).
4. Move the middle handle of the arrow.
5. It should curve the arrow.

---

1. Open this snapshot link:
https://www.tldraw.com/s/v2_c_LtB3kVSYEyWuR-aCCrrUn
2. Copy its contents onto your own tldraw.
3. Click on the frog.
4. Drag the handle that's on the frog's face.
5. It shouldn't crash the app.

- [ ] Unit Tests
- [ ] Webdriver tests

### Release Notes

- Fixed a rare crash that could happen when you try to curve an arrow
with zero distance.
2023-06-06 13:30:50 +00:00
Steve Ruiz
1753190f5c
[feature] add vertical align to note shape (#1539)
This PR adds vertical align to the note shape.

### Change Type

- [x] `minor` — New Feature

### Test Plan

1. Try the vertical align prop on note shapes

### Release Notes

- Adds vertical align prop to note shapes
2023-06-06 13:27:32 +00:00
Steve Ruiz
8d1817a3e3
Use "Toggle locked" (#1538)
Use toggle locked rather than Lock / Unlock

### Change Type

- [x] `patch` — Bug Fix
2023-06-06 11:52:26 +00:00
Steve Ruiz
b89612bdb7
[fix] Shift key code / nudge (#1537)
Fix key code when pressing Shift, which fixes nudging.

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. use the shift key to nudge things

### Release Notes

- Fix shift key nudging
2023-06-06 11:49:17 +00:00
alex
66b3de4a03
scale exported canvases when they reach the browsers max size (#1536)
Uses https://github.com/jhildenbiddle/canvas-size to determine the max
supported canvas size of the current browser, then scales exports
accordingly.

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


### Test Plan

Tested locally across a few browsers

### Release Notes

- Fix a bug where sometimes exports would fail when they were too big
for your browser. Now, they're scaled down to the max supported size.
2023-06-06 11:44:21 +00:00
Steve Ruiz
6f8533df5d
[fix] control click on mac (#1535)
This PR fixes control click for right click on Mac.

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. On a PC, ensure that control clicking does not select the thing under
your cursor
2. On a mac, ensure that control clicking does select the thing under
your cursor before the context menu opens

### Release Notes

- Fix control click to open menu on Mac
2023-06-06 11:30:52 +00:00
Lu Wilson
7039c3772e
Fix being able to undo following (#1531)
This PR fixes a bug where you could undo following/unfollowing.

Fixes #1532

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. In two browser sessions...
2. In a shared project...
3. Follow the other tab's user.
4. Draw something.
5. Unfollow them.
6. Close the people menu!
7. Undo as far as you can go.
8. Check that you don't start following them again at any point.

- [ ] Unit Tests
- [ ] Webdriver tests

### Release Notes

- Fixed a bug where you could undo viewport-following and
viewport-unfollowing.
2023-06-06 11:25:14 +00:00
Steve Ruiz
9e1b679e3b
Select locked shapes on long press (#1529)
Fixes https://github.com/tldraw/tldraw/issues/1534

### Change Type

- [x] `patch` — Bug Fix

### Test Plan

1. On a touch device, create a locked shape
2. Long press on the locked shape to select it and open the context menu

### Release Notes
2023-06-06 11:23:53 +00:00
alex
d9548556cb
highlighter fixes (#1530)
Fixes the following issues with highlighter:
* Exported highlighter has much larger stroke width than in-app
highlighter
* Selecting two highlighter shapes with different sizes would hide the
size option from the styles panel
* Highlighter lines drawn on ipad look noise-y

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

-

### Release Notes

[aq bug fixes]
2023-06-06 11:06:28 +00:00
Lu Wilson
d646994554
Lokalise: Translations update (#1515)
## Release Notes
- Added and updated community translations for Galician, Italian,
Romanian, Russian, Ukrainian, and Traditional Chinese.
2023-06-05 18:05:10 +00:00
Steve Ruiz
3be19ad53e
ensure that fixed points stay fixed (#1523)
This PR fixes points on resize as well as on create. This should help
with file size for large resizes.

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

### Test Plan

- [ ] Unit Tests
2023-06-05 18:04:13 +00:00
David Sheldrick
a4fff303bf update lazyrepo 2023-06-05 18:32:32 +01:00
David Sheldrick
4012666cab
Reinstate auto (#1524)
Follow up to #1521 

Turns out we accidentally removed auto from the repo in #1488 !!
2023-06-05 16:13:26 +00:00
Steve Ruiz
2fc70a7b37
Update examples links to point to examples folder. (#1522)
This PR updates the docs examples links to point to the examples folder.

### Change Type

- [x] `documentation` — Changes to the documentation only (will not
publish a new version)
2023-06-05 14:52:28 +00:00
Steve Ruiz
1f0a20cc94
Simplify static cursors (#1520)
This PR simplifies the static cursors.

### Change Type

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

### Test Plan

1. Use cursors throughout app.

### Release Notes

- (editor) Simplifies the cursors in our CSS.
2023-06-05 14:49:44 +00:00
David Sheldrick
9c71f23a85
[infra] use npx to run auto (#1521)
The canary release failed due to not finding auto:
https://github.com/tldraw/tldraw/actions/runs/5178225013/jobs/9329393446

No idea why, but I'm going to try running it with npx here.
2023-06-05 14:46:59 +00:00
David Sheldrick
f15a8797f0
Independent instance state persistence (#1493)
This PR 

- Removes UserDocumentRecordType
  - moving isSnapMode to user preferences
  - moving isGridMode and isPenMode to InstanceRecordType
  - deleting the other properties which are no longer needed.
 
- Creates a separate pipeline for persisting instance state.
  
Previously the instance state records were stored alongside the document
state records, and in order to load the state for a particular instance
(in our case, a particular tab) you needed to pass the 'instanceId'
prop. This prop ended up totally pervading the public API and people ran
into all kinds of issues with it, e.g. using the same instance id in
multiple editor instances.

There was also an issue whereby it was hard for us to clean up old
instance state so the idb table ended up bloating over time.
  
This PR makes it so that rather than passing an instanceId, you load the
instance state yourself while creating the store. It provides tools to
make that easy.

- Undoes the assumption that we might have more than one instance's
state in the store.

- Like `document`, `instance` now has a singleton id
`instance:instance`.
- Page state ids and camera ids are no longer random, but rather derive
from the page they belong to. This is like having a foreign primary key
in SQL databases. It's something i'd love to support fully as part of
the RecordType/Store api.

Tests to do

- [x] Test Migrations
- [x] Test Store.listen filtering
- [x] Make type sets in Store public and readonly
- [x] Test RecordType.createId
- [x] Test Instance state snapshot loading/exporting
- [x] Manual test File I/O
- [x] Manual test Vscode extension with multiple tabs
- [x] Audit usages of store.query
- [x] Audit usages of changed types: InstanceRecordType, 'instance',
InstancePageStateRecordType, 'instance_page_state', 'user_document',
'camera', CameraRecordType, InstancePresenceRecordType,
'instance_presence'
- [x] Test user preferences
- [x] Manual test isSnapMode and isGridMode and isPenMode
- [ ] Test indexedDb functions
- [x] Add instanceId stuff back


### Change Type

- [x] `major` — Breaking Change


### 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-06-05 14:11:07 +00:00
Steve Ruiz
0f89309604
Renaming types, shape utils, tools (#1513)
This PR renames all exported types to include the `TL` prefix. It also
removes the `TL` prefix from things that are not types, including:
- shape utils (e.g. `TLArrowUtil` becomes `ArrowShapeUtil`)
- tools (e.g. `TLArrowTool` becomes `ArrowShapeTool`, `TLSelectTool`
becomes `SelectTool`)

### Change Type

- [x] `major` — Breaking Change

### Release Notes

- Renaming of types, shape utils, tools
2023-06-04 10:38:53 +00:00
Steve Ruiz
10bb677035
restore styles sets exports (#1512)
This PR restores the sets into schema exports so that they can be picked
up by check translations script.

### Change Type

- [x] `internal` — Any other changes that don't affect the published
package (will not publish a new version)
2023-06-03 21:32:14 +00:00