Remove helpers / extraneous API methods. (#1745)

This PR removes several extraneous computed values from the editor. It
adds some silly instance state onto the instance state record and
unifies a few methods which were inconsistent. This is fit and finish
work 🧽

## Computed Values

In general, where once we had a getter and setter for `isBlahMode`,
which really masked either an `_isBlahMode` atom on the editor or
`instanceState.isBlahMode`, these are merged into `instanceState`; they
can be accessed / updated via `editor.instanceState` /
`editor.updateInstanceState`.

## tldraw select tool specific things

This PR also removes some tldraw specific state checks and creates new
component overrides to allow us to include them in tldraw/tldraw.

### Change Type

- [x] `major` — Breaking change

### Test Plan

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

### Release Notes

- [tldraw] rename `useReadonly` to `useReadOnly`
- [editor] remove `Editor.isDarkMode`
- [editor] remove `Editor.isChangingStyle`
- [editor] remove `Editor.isCoarsePointer`
- [editor] remove `Editor.isDarkMode`
- [editor] remove `Editor.isFocused`
- [editor] remove `Editor.isGridMode`
- [editor] remove `Editor.isPenMode`
- [editor] remove `Editor.isReadOnly`
- [editor] remove `Editor.isSnapMode`
- [editor] remove `Editor.isToolLocked`
- [editor] remove `Editor.locale`
- [editor] rename `Editor.pageState` to `Editor.currentPageState`
- [editor] add `Editor.pageStates`
- [editor] add `Editor.setErasingIds`
- [editor] add `Editor.setEditingId`
- [editor] add several new component overrides
This commit is contained in:
Steve Ruiz 2023-07-18 22:50:23 +01:00 committed by GitHub
parent a7d3a77cb0
commit 3e31ef2a7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
154 changed files with 1728 additions and 1706 deletions

View file

@ -45,12 +45,13 @@ export const InnerIndicator = ({ editor, id }: { editor: Editor; id: TLShapeId }
)
}
export type TLShapeIndicatorComponent = (props: {
/** @public */
export type TLShapeIndicatorComponent = React.ComponentType<{
id: TLShapeId
color?: string | undefined
opacity?: number
className?: string
}) => JSX.Element | null
}>
const _ShapeIndicator: TLShapeIndicatorComponent = ({ id, className, color, opacity }) => {
const editor = useEditor()
@ -79,4 +80,5 @@ const _ShapeIndicator: TLShapeIndicatorComponent = ({ id, className, color, opac
)
}
/** @public */
export const ShapeIndicator = React.memo(_ShapeIndicator)