Move constants to options prop (#3799)

Another go at #3628 & #3783. This moves (most) constants into
`editor.options`, configurable by the `options` prop on the tldraw
component.

### Change Type

- [x] `sdk` — Changes the tldraw SDK
- [x] `feature` — New feature

### Release Notes

You can now override many options which were previously hard-coded
constants. Pass an `options` prop into the tldraw component to change
the maximum number of pages, grid steps, or other previously hard-coded
values. See `TldrawOptions` for more
This commit is contained in:
alex 2024-05-28 15:22:03 +01:00 committed by GitHub
parent 19f8d4248c
commit a457a39081
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 347 additions and 267 deletions

View file

@ -1,6 +1,7 @@
import { TLHandle, TLShapeId } from '@tldraw/tlschema'
import classNames from 'classnames'
import { COARSE_HANDLE_RADIUS, HANDLE_RADIUS, SIDES } from '../../constants'
import { SIDES } from '../../constants'
import { useEditor } from '../../hooks/useEditor'
/** @public */
export interface TLHandleProps {
@ -13,7 +14,8 @@ export interface TLHandleProps {
/** @public */
export function DefaultHandle({ handle, isCoarse, className, zoom }: TLHandleProps) {
const br = (isCoarse ? COARSE_HANDLE_RADIUS : HANDLE_RADIUS) / zoom
const editor = useEditor()
const br = (isCoarse ? editor.options.coarseHandleRadius : editor.options.handleRadius) / zoom
if (handle.type === 'clone') {
// bouba