[refactor] Remove TLShapeDef, getShapeUtilByType. (#1432)

This PR removes `TLShapeDef` and associated helpers / references.

It purposely loosens the configuration and typings to better support
customization.

### Change Type

- [x] `major` — Breaking Change

### Test Plan

1. Use the app!

### Release Notes

- [tlschema] Update props of `createTLSchema`
- [editor] Update props of `TldrawEditorConfig`
- [editor] Remove `App.getShapeUtilByType`
- [editor] Update `App.getShapeUtil` to take a type rather than a shape

---------

Co-authored-by: alex <alex@dytry.ch>
This commit is contained in:
Steve Ruiz 2023-05-23 13:32:42 +01:00 committed by GitHub
parent 3ce18c0c31
commit 649125cdad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
55 changed files with 527 additions and 690 deletions

View file

@ -3,12 +3,12 @@ import {
getValidHttpURLList,
isSvgText,
isValidHttpURL,
TLArrowShapeDef,
TLBookmarkShapeDef,
TLArrowUtil,
TLBookmarkUtil,
TLClipboardModel,
TLEmbedShapeDef,
TLGeoShapeDef,
TLTextShapeDef,
TLEmbedUtil,
TLGeoUtil,
TLTextUtil,
useApp,
} from '@tldraw/editor'
import { VecLike } from '@tldraw/primitives'
@ -495,10 +495,14 @@ const handleNativeOrMenuCopy = (app: App) => {
// Extract the text from the clipboard
const textItems = content.shapes
.map((shape) => {
if (TLTextShapeDef.is(shape) || TLGeoShapeDef.is(shape) || TLArrowShapeDef.is(shape)) {
if (
app.isShapeOfType(shape, TLTextUtil) ||
app.isShapeOfType(shape, TLGeoUtil) ||
app.isShapeOfType(shape, TLArrowUtil)
) {
return shape.props.text
}
if (TLBookmarkShapeDef.is(shape) || TLEmbedShapeDef.is(shape)) {
if (app.isShapeOfType(shape, TLBookmarkUtil) || app.isShapeOfType(shape, TLEmbedUtil)) {
return shape.props.url
}
return null