kopia lustrzana https://github.com/Tldraw/Tldraw
Use the same types.
rodzic
e2e9c50e03
commit
999a33d4ec
|
@ -2194,7 +2194,7 @@ export interface TLErrorBoundaryProps {
|
|||
|
||||
// @public (undocumented)
|
||||
export type TLErrorEvent = {
|
||||
type: 'max-shapes';
|
||||
type: TLEditorErrorType;
|
||||
value: [{
|
||||
count: number;
|
||||
name: string;
|
||||
|
|
|
@ -8520,7 +8520,7 @@ export class Editor extends EventEmitter<TLEventMap> {
|
|||
function alertMaxShapes(editor: Editor, pageId = editor.getCurrentPageId()) {
|
||||
const name = editor.getPage(pageId)!.name
|
||||
editor.emit('error', {
|
||||
type: 'max-shapes',
|
||||
type: 'max-shapes-reached',
|
||||
value: [{ name, pageId, count: MAX_SHAPES_PER_PAGE }],
|
||||
})
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ export const EditorResult = {
|
|||
},
|
||||
}
|
||||
|
||||
// All errors
|
||||
export type TLEditorErrorType = CreateShapeErrorType | (typeof READONLY_ROOM_ERROR)['type']
|
||||
|
||||
// General errors
|
||||
/** @public */
|
||||
export const READONLY_ROOM_ERROR = { type: 'readonly-room' as const, message: 'Room is readonly' }
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { HistoryEntry } from '@tldraw/store'
|
||||
import { TLPageId, TLRecord, TLShapeId } from '@tldraw/tlschema'
|
||||
import { TLEditorErrorType } from './editor-result-types'
|
||||
import { TLEventInfo } from './event-types'
|
||||
|
||||
/** @public */
|
||||
export type TLErrorEvent = {
|
||||
type: 'max-shapes'
|
||||
type: TLEditorErrorType
|
||||
value: [{ name: string; pageId: TLPageId; count: number }]
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ export function useEditorEvents() {
|
|||
|
||||
useEffect(() => {
|
||||
function handleMaxShapes(error: TLErrorEvent) {
|
||||
if (error.type !== 'max-shapes') return
|
||||
if (error.type !== 'max-shapes-reached') return
|
||||
const [{ name, count }] = error.value
|
||||
addToast({
|
||||
title: 'Maximum Shapes Reached',
|
||||
|
|
Ładowanie…
Reference in New Issue