Fix types

This commit is contained in:
Steve Ruiz 2021-08-30 11:49:49 +01:00
parent 64d00dc427
commit b7902f3ce8
3 changed files with 7 additions and 10 deletions

View file

@ -2,21 +2,19 @@ import { useTLContext } from '+hooks'
import * as React from 'react' import * as React from 'react'
import type { TLShapeUtil, TLRenderInfo, TLShape } from '+types' import type { TLShapeUtil, TLRenderInfo, TLShape } from '+types'
interface EditingShapeProps<T extends TLShape, M extends Record<string, unknown>> interface EditingShapeProps<T extends TLShape> extends TLRenderInfo {
extends TLRenderInfo {
shape: T shape: T
utils: TLShapeUtil<T> utils: TLShapeUtil<T>
meta?: M
} }
export function EditingTextShape<M extends Record<string, unknown>>({ export function EditingTextShape({
shape, shape,
utils, utils,
isEditing, isEditing,
isBinding, isBinding,
isCurrentParent, isCurrentParent,
meta, meta,
}: EditingShapeProps<TLShape, M>) { }: EditingShapeProps<TLShape>) {
const { const {
callbacks: { onTextChange, onTextBlur, onTextFocus, onTextKeyDown, onTextKeyUp }, callbacks: { onTextChange, onTextBlur, onTextFocus, onTextKeyDown, onTextKeyUp },
} = useTLContext() } = useTLContext()

View file

@ -1,22 +1,20 @@
import * as React from 'react' import * as React from 'react'
import type { TLShapeUtil, TLRenderInfo, TLShape } from '+types' import type { TLShapeUtil, TLRenderInfo, TLShape } from '+types'
interface RenderedShapeProps<T extends TLShape, M extends Record<string, unknown>> interface RenderedShapeProps<T extends TLShape> extends TLRenderInfo {
extends TLRenderInfo {
shape: T shape: T
utils: TLShapeUtil<T> utils: TLShapeUtil<T>
meta?: M
} }
export const RenderedShape = React.memo( export const RenderedShape = React.memo(
function RenderedShape<M extends Record<string, unknown>>({ function RenderedShape({
shape, shape,
utils, utils,
isEditing, isEditing,
isBinding, isBinding,
isCurrentParent, isCurrentParent,
meta, meta,
}: RenderedShapeProps<TLShape, M>) { }: RenderedShapeProps<TLShape>) {
return utils.render(shape, { return utils.render(shape, {
isEditing, isEditing,
isBinding, isBinding,

View file

@ -53,6 +53,7 @@ export function TLDraw({ document, currentPageId, onMount, onChange: _onChange }
// Hide indicators when not using the select tool, or when in session // Hide indicators when not using the select tool, or when in session
const hideIndicators = !isSelecting || isInSession const hideIndicators = !isSelecting || isInSession
// Custom rendering meta, with dark mode for shapes
const meta = React.useMemo(() => ({ isDarkMode }), [isDarkMode]) const meta = React.useMemo(() => ({ isDarkMode }), [isDarkMode])
React.useEffect(() => { React.useEffect(() => {