Remove references to core, fix core example

This commit is contained in:
Steve Ruiz 2021-10-29 15:00:55 +01:00
parent a8377139ab
commit b6f2e2940f
3 changed files with 72 additions and 85 deletions

View file

@ -2,16 +2,7 @@
/* refresh-reset */ /* refresh-reset */
import * as React from 'react' import * as React from 'react'
import { import { TLShape, Utils, TLBounds, TLShapeUtil, HTMLContainer, SVGContainer } from '@tldraw/core'
TLShape,
Utils,
TLBounds,
TLShapeUtil,
HTMLContainer,
TLComponent,
SVGContainer,
TLIndicator,
} from '@tldraw/core'
// Define a custom shape // Define a custom shape
@ -37,11 +28,8 @@ export const boxShape: BoxShape = {
export class BoxUtil extends TLShapeUtil<BoxShape, HTMLDivElement> { export class BoxUtil extends TLShapeUtil<BoxShape, HTMLDivElement> {
age = 100 age = 100
Component: TLComponent<BoxShape, HTMLDivElement> = ( Component = TLShapeUtil.Component<BoxShape, HTMLDivElement>(
{ shape, events, onShapeChange, isEditing, meta }, ({ shape, events, onShapeChange, isEditing, meta }, ref) => {
ref
) => {
console.log('hi')
const color = meta.isDarkMode ? 'white' : 'black' const color = meta.isDarkMode ? 'white' : 'black'
const rInput = React.useRef<HTMLDivElement>(null) const rInput = React.useRef<HTMLDivElement>(null)
@ -115,8 +103,9 @@ export class BoxUtil extends TLShapeUtil<BoxShape, HTMLDivElement> {
</HTMLContainer> </HTMLContainer>
) )
} }
)
Indicator: TLIndicator<BoxShape> = ({ shape }) => { Indicator = TLShapeUtil.Indicator<BoxShape>(({ shape }) => {
return ( return (
<SVGContainer> <SVGContainer>
<rect <rect
@ -129,7 +118,7 @@ export class BoxUtil extends TLShapeUtil<BoxShape, HTMLDivElement> {
/> />
</SVGContainer> </SVGContainer>
) )
} })
getBounds = (shape: BoxShape) => { getBounds = (shape: BoxShape) => {
const bounds = Utils.getFromCache(this.boundsCache, shape, () => { const bounds = Utils.getFromCache(this.boundsCache, shape, () => {

View file

@ -9,7 +9,6 @@
"emitDeclarationOnly": false, "emitDeclarationOnly": false,
"paths": { "paths": {
"+*": ["./*"], "+*": ["./*"],
"@tldraw/core": ["../core"],
"@tldraw/tldraw": ["../tldraw"] "@tldraw/tldraw": ["../tldraw"]
} }
}, },

View file

@ -8,7 +8,6 @@
"baseUrl": "src", "baseUrl": "src",
"paths": { "paths": {
"~*": ["./*"], "~*": ["./*"],
"@tldraw/core": ["../core"],
"@tldraw/vec": ["../vec"], "@tldraw/vec": ["../vec"],
"@tldraw/intersect": ["../intersect"] "@tldraw/intersect": ["../intersect"]
} }