No description
Find a file
Steve Ruiz 0c5f8dda48
1.0.0 (#267)
* remove sponsorwall for main route

* Adds sponsorship link

* Remove all sponsorwall

* Fix sponsorship link appearance on dark mode

* Add heart icon

* Fix text bug

* Fix toolbar, hide resize handles on sticky

* Add eraser

* Update Kbd.tsx

* cleanup

* base zoom delta on event deltaMode

* Fix image in example

* Fix eraser icon

* eraser tool resets to previous tool

* Update EraseTool.spec.ts

* Improves support for locked shapes

* Update _document.tsx

* Update CHANGELOG.md

* Adds multiplayer menu, fix develop route in example

* Tighten up top panel padding

* Update top bar, bump packages

* refactor TLDrawState -> TLDrawApp, mutables, new tests

* Fix scaling bug, delete groups bug

* fix snapping

* add pressure to points

* Remove mutables, rename to tldraw (or Tldraw)

* Clean up types, add darkmode prop

* more renaming

* rename getShapeUtils to getShapeUtil

* Fix file names

* Fix last bugs related to renaming

* Update state to app in tests

* rename types to TD

* remove unused styles / rename styles

* slight update to panel

* Fix rogue radix perf issue

* Update ZoomMenu.tsx

* Consolidate style panel

* Fix text wrapping in text shape, improve action menu

* Fix props

* add indicators for tool lock

* fix calloits

* Add click to erase shapes

* Slightly improve loading screen

* Update PrimaryTools.tsx

* remove force consistent filenames from tsconfig

* Update useTldrawApp.tsx

* fix capitalization

* Update main.yml
2021-11-16 16:01:29 +00:00
.github 1.0.0 (#267) 2021-11-16 16:01:29 +00:00
.husky [mega-chore] renaming (#223) 2021-11-06 11:16:30 +00:00
.vscode big refactor 2021-09-13 16:38:42 +01:00
electron 1.0.0 (#267) 2021-11-16 16:01:29 +00:00
example 1.0.0 (#267) 2021-11-16 16:01:29 +00:00
guides 1.0.0 (#267) 2021-11-16 16:01:29 +00:00
packages/tldraw 1.0.0 (#267) 2021-11-16 16:01:29 +00:00
vscode 1.0.0 (#267) 2021-11-16 16:01:29 +00:00
www 1.0.0 (#267) 2021-11-16 16:01:29 +00:00
.eslintignore Prepare for Publishing VS Code Extension (#227) 2021-11-10 15:35:51 +00:00
.eslintrc Prepare for Publishing VS Code Extension (#227) 2021-11-10 15:35:51 +00:00
.gitignore 1.0.0 (#267) 2021-11-16 16:01:29 +00:00
.npmignore Replace 2021-08-10 17:12:55 +01:00
.prettierrc Prepare for Publishing VS Code Extension (#227) 2021-11-10 15:35:51 +00:00
card-repo.png [improvement] repo shuffle (#214) 2021-11-02 11:46:25 +00:00
CODE_OF_CONDUCT.md updates docs / readmes / adds contributor guide 2021-11-11 12:11:21 +00:00
CONTRIBUTING.md 1.0.0 (#267) 2021-11-16 16:01:29 +00:00
lerna.json v0.1.17 2021-11-12 22:30:04 +00:00
LICENSE.md [improvement] UI (#215) 2021-11-03 16:46:33 +00:00
package.json 1.0.0 (#267) 2021-11-16 16:01:29 +00:00
README.md 1.0.0 (#267) 2021-11-16 16:01:29 +00:00
setupTests.ts Adjusts small example, makes inputs unique to each instance 2021-09-08 17:18:43 +01:00
tsconfig.base.json 1.0.0 (#267) 2021-11-16 16:01:29 +00:00
tsconfig.json Remove libraries 2021-11-01 15:26:44 +00:00
yarn.lock 1.0.0 (#267) 2021-11-16 16:01:29 +00:00

@tldraw/tldraw

This package contains the tldraw editor as a React component named <Tldraw>. You can use this package to embed the editor in any React application.

💕 Love this library? Consider becoming a sponsor.

🙌 Questions? Join the Discord channel or start a discussion.

🎨 Want to build your own tldraw-ish app instead? Try @tldraw/core.

Installation

Use your package manager of choice to install @tldraw/tldraw and its peer dependencies.

yarn add @tldraw/tldraw
# or
npm i @tldraw/tldraw

Usage

Import the tldraw React component and use it in your app.

import { Tldraw } from '@tldraw/tldraw'

function App() {
  return <Tldraw />
}

Persisting the State

You can use the id to persist the state in a user's browser storage.

import { Tldraw } from '@tldraw/tldraw'

function App() {
  return <Tldraw id="myState" />
}

Controlling the Component through Props

You can control the tldraw component through its props.

import { Tldraw, TDDocument } from '@tldraw/tldraw'

function App() {
  const myDocument: TDDocument = {}

  return <Tldraw document={document} />
}

Controlling the Component through the tldrawApp API

You can also control the tldraw component imperatively through the tldrawApp API.

import { Tldraw, tldrawApp } from '@tldraw/tldraw'

function App() {
  const handleMount = React.useCallback((state: tldrawApp) => {
    state.selectAll()
  }, [])

  return <Tldraw onMount={handleMount} />
}

Internally, the tldraw component's user interface uses this API to make changes to the component's state. See the tldrawApp section of the documentation for more on this API.

Responding to Changes

You can respond to changes and user actions using the onChange callback. For more specific changes, you can also use the onPatch, onCommand, or onPersist callbacks. See the documentation for more.

import { Tldraw, tldrawApp } from '@tldraw/tldraw'

function App() {
  const handleChange = React.useCallback((state: tldrawApp, reason: string) => {
    // Do something with the change
  }, [])

  return <Tldraw onMount={handleMount} />
}

Documentation

See the project's documentation.

Contribution

See the contributing guide.

Development

See the development guide.

Example

See the example folder for examples of how to use the <Tldraw/> component.

Community

Support

Need help? Please open an issue for support.

Discussion

Want to connect with other devs? Visit the Discord channel.

License

This project is licensed under MIT.

If you're using the library in a commercial product, please consider becoming a sponsor.

Author