1927f88041
Based on #1549, but with a lot of code-structure related changes backed out. Shape schemas are still defined in tlschemas with this diff. Couple differences between this and #1549: - This tightens up the relationship between store schemas and editor schemas a bit - Reduces the number of places we need to remember to include core shapes - Only `<TLdrawEditor />` sets default shapes by default. If you're doing something funky with lower-level APIs, you need to specify `defaultShapes` manually - Replaces `validator` with `props` for shapes ### Change Type - [x] `major` — Breaking Change ### Test Plan 1. Add a step-by-step description of how to test your PR here. 2. - [x] Unit Tests - [ ] Webdriver tests ### Release Notes [dev-facing, notes to come]
259 lines
8.1 KiB
TypeScript
259 lines
8.1 KiB
TypeScript
// Important! don't move this tlschema re-export to lib/index.ts, doing so causes esbuild to produce
|
|
// incorrect output. https://github.com/evanw/esbuild/issues/1737
|
|
|
|
// eslint-disable-next-line local/no-export-star
|
|
export * from '@tldraw/indices'
|
|
// eslint-disable-next-line local/no-export-star
|
|
export * from '@tldraw/tlschema'
|
|
export { getHashForString } from '@tldraw/utils'
|
|
export {
|
|
ErrorScreen,
|
|
LoadingScreen,
|
|
TldrawEditor,
|
|
type TldrawEditorProps,
|
|
} from './lib/TldrawEditor'
|
|
export {
|
|
defaultEditorAssetUrls,
|
|
setDefaultEditorAssetUrls,
|
|
type TLEditorAssetUrls,
|
|
} from './lib/assetUrls'
|
|
export { Canvas } from './lib/components/Canvas'
|
|
export { DefaultErrorFallback } from './lib/components/DefaultErrorFallback'
|
|
export {
|
|
ErrorBoundary,
|
|
OptionalErrorBoundary,
|
|
type TLErrorBoundaryProps,
|
|
} from './lib/components/ErrorBoundary'
|
|
export { HTMLContainer, type HTMLContainerProps } from './lib/components/HTMLContainer'
|
|
export { SVGContainer, type SVGContainerProps } from './lib/components/SVGContainer'
|
|
export {
|
|
TAB_ID,
|
|
createSessionStateSnapshotSignal,
|
|
extractSessionStateFromLegacySnapshot,
|
|
loadSessionStateSnapshotIntoStore,
|
|
type TLSessionStateSnapshot,
|
|
} from './lib/config/TLSessionStateSnapshot'
|
|
export {
|
|
USER_COLORS,
|
|
getUserPreferences,
|
|
setUserPreferences,
|
|
type TLUserPreferences,
|
|
} from './lib/config/TLUserPreferences'
|
|
export {
|
|
createTLStore,
|
|
type TLStoreEventInfo,
|
|
type TLStoreOptions,
|
|
} from './lib/config/createTLStore'
|
|
export { coreShapes, defaultShapes } from './lib/config/defaultShapes'
|
|
export { defaultTools } from './lib/config/defaultTools'
|
|
export { defineShape, type TLShapeInfo } from './lib/config/defineShape'
|
|
export {
|
|
ANIMATION_MEDIUM_MS,
|
|
ANIMATION_SHORT_MS,
|
|
ARROW_LABEL_FONT_SIZES,
|
|
BOUND_ARROW_OFFSET,
|
|
DEFAULT_ANIMATION_OPTIONS,
|
|
DEFAULT_BOOKMARK_HEIGHT,
|
|
DEFAULT_BOOKMARK_WIDTH,
|
|
DOUBLE_CLICK_DURATION,
|
|
DRAG_DISTANCE,
|
|
FONT_ALIGNMENT,
|
|
FONT_FAMILIES,
|
|
FONT_SIZES,
|
|
GRID_INCREMENT,
|
|
GRID_STEPS,
|
|
HAND_TOOL_FRICTION,
|
|
HASH_PATERN_ZOOM_NAMES,
|
|
ICON_SIZES,
|
|
LABEL_FONT_SIZES,
|
|
MAJOR_NUDGE_FACTOR,
|
|
MAX_ASSET_HEIGHT,
|
|
MAX_ASSET_WIDTH,
|
|
MAX_PAGES,
|
|
MAX_SHAPES_PER_PAGE,
|
|
MAX_ZOOM,
|
|
MINOR_NUDGE_FACTOR,
|
|
MIN_ARROW_LENGTH,
|
|
MIN_ZOOM,
|
|
MULTI_CLICK_DURATION,
|
|
REMOVE_SYMBOL,
|
|
RICH_TYPES,
|
|
ROTATING_SHADOWS,
|
|
STYLES,
|
|
SVG_PADDING,
|
|
TEXT_PROPS,
|
|
WAY_TOO_BIG_ARROW_BEND_FACTOR,
|
|
ZOOMS,
|
|
} from './lib/constants'
|
|
export { Editor, type TLAnimationOptions, type TLEditorOptions } from './lib/editor/Editor'
|
|
export {
|
|
ExternalContentManager as PlopManager,
|
|
type TLExternalContent,
|
|
} from './lib/editor/managers/ExternalContentManager'
|
|
export { ArrowShapeUtil } from './lib/editor/shapeutils/ArrowShapeUtil/ArrowShapeUtil'
|
|
export { BaseBoxShapeUtil, type TLBaseBoxShape } from './lib/editor/shapeutils/BaseBoxShapeUtil'
|
|
export { BookmarkShapeUtil } from './lib/editor/shapeutils/BookmarkShapeUtil/BookmarkShapeUtil'
|
|
export { DrawShapeUtil } from './lib/editor/shapeutils/DrawShapeUtil/DrawShapeUtil'
|
|
export { EmbedShapeUtil } from './lib/editor/shapeutils/EmbedShapeUtil/EmbedShapeUtil'
|
|
export { FrameShapeUtil } from './lib/editor/shapeutils/FrameShapeUtil/FrameShapeUtil'
|
|
export { GeoShapeUtil } from './lib/editor/shapeutils/GeoShapeUtil/GeoShapeUtil'
|
|
export { GroupShapeUtil } from './lib/editor/shapeutils/GroupShapeUtil/GroupShapeUtil'
|
|
export { HighlightShapeUtil } from './lib/editor/shapeutils/HighlightShapeUtil/HighlightShapeUtil'
|
|
export { ImageShapeUtil } from './lib/editor/shapeutils/ImageShapeUtil/ImageShapeUtil'
|
|
export {
|
|
LineShapeUtil,
|
|
getSplineForLineShape,
|
|
} from './lib/editor/shapeutils/LineShapeUtil/LineShapeUtil'
|
|
export { NoteShapeUtil } from './lib/editor/shapeutils/NoteShapeUtil/NoteShapeUtil'
|
|
export {
|
|
ShapeUtil,
|
|
type TLOnBeforeCreateHandler,
|
|
type TLOnBeforeUpdateHandler,
|
|
type TLOnBindingChangeHandler,
|
|
type TLOnChildrenChangeHandler,
|
|
type TLOnClickHandler,
|
|
type TLOnDoubleClickHandleHandler,
|
|
type TLOnDoubleClickHandler,
|
|
type TLOnDragHandler,
|
|
type TLOnEditEndHandler,
|
|
type TLOnHandleChangeHandler,
|
|
type TLOnResizeEndHandler,
|
|
type TLOnResizeHandler,
|
|
type TLOnResizeStartHandler,
|
|
type TLOnRotateEndHandler,
|
|
type TLOnRotateHandler,
|
|
type TLOnRotateStartHandler,
|
|
type TLOnTranslateEndHandler,
|
|
type TLOnTranslateHandler,
|
|
type TLOnTranslateStartHandler,
|
|
type TLResizeInfo,
|
|
type TLResizeMode,
|
|
type TLShapeUtilConstructor,
|
|
type TLShapeUtilFlag,
|
|
} from './lib/editor/shapeutils/ShapeUtil'
|
|
export { INDENT, TextShapeUtil } from './lib/editor/shapeutils/TextShapeUtil/TextShapeUtil'
|
|
export { VideoShapeUtil } from './lib/editor/shapeutils/VideoShapeUtil/VideoShapeUtil'
|
|
export { BaseBoxShapeTool } from './lib/editor/tools/BaseBoxShapeTool/BaseBoxShapeTool'
|
|
export { StateNode, type TLStateNodeConstructor } from './lib/editor/tools/StateNode'
|
|
export { type TLContent } from './lib/editor/types/clipboard-types'
|
|
export { type TLEventMap, type TLEventMapHandler } from './lib/editor/types/emit-types'
|
|
export {
|
|
EVENT_NAME_MAP,
|
|
type TLBaseEventInfo,
|
|
type TLCLickEventName,
|
|
type TLCancelEvent,
|
|
type TLCancelEventInfo,
|
|
type TLClickEvent,
|
|
type TLClickEventInfo,
|
|
type TLCompleteEvent,
|
|
type TLCompleteEventInfo,
|
|
type TLEnterEventHandler,
|
|
type TLEventHandlers,
|
|
type TLEventInfo,
|
|
type TLEventName,
|
|
type TLExitEventHandler,
|
|
type TLInterruptEvent,
|
|
type TLInterruptEventInfo,
|
|
type TLKeyboardEvent,
|
|
type TLKeyboardEventInfo,
|
|
type TLKeyboardEventName,
|
|
type TLPinchEvent,
|
|
type TLPinchEventInfo,
|
|
type TLPinchEventName,
|
|
type TLPointerEvent,
|
|
type TLPointerEventInfo,
|
|
type TLPointerEventName,
|
|
type TLPointerEventTarget,
|
|
type TLTickEvent,
|
|
type TLWheelEvent,
|
|
type TLWheelEventInfo,
|
|
type UiEvent,
|
|
type UiEventType,
|
|
} from './lib/editor/types/event-types'
|
|
export {
|
|
type TLCommand,
|
|
type TLCommandHandler,
|
|
type TLHistoryEntry,
|
|
type TLHistoryMark,
|
|
} from './lib/editor/types/history-types'
|
|
export { type RequiredKeys } from './lib/editor/types/misc-types'
|
|
export { type TLResizeHandle, type TLSelectionHandle } from './lib/editor/types/selection-types'
|
|
export { normalizeWheel } from './lib/hooks/shared'
|
|
export { useContainer } from './lib/hooks/useContainer'
|
|
export { useEditor } from './lib/hooks/useEditor'
|
|
export type { TLEditorComponents } from './lib/hooks/useEditorComponents'
|
|
export { useLocalStore } from './lib/hooks/useLocalStore'
|
|
export { usePeerIds } from './lib/hooks/usePeerIds'
|
|
export { usePresence } from './lib/hooks/usePresence'
|
|
export { useQuickReactor } from './lib/hooks/useQuickReactor'
|
|
export { useReactor } from './lib/hooks/useReactor'
|
|
export { useTLStore } from './lib/hooks/useTLStore'
|
|
export { WeakMapCache } from './lib/utils/WeakMapCache'
|
|
export {
|
|
ACCEPTED_ASSET_TYPE,
|
|
ACCEPTED_IMG_TYPE,
|
|
ACCEPTED_VID_TYPE,
|
|
containBoxSize,
|
|
dataUrlToFile,
|
|
getFileMetaData,
|
|
getImageSizeFromSrc,
|
|
getMediaAssetFromFile,
|
|
getResizedImageDataUrl,
|
|
getValidHttpURLList,
|
|
getVideoSizeFromSrc,
|
|
isImage,
|
|
isSvgText,
|
|
isValidHttpURL,
|
|
} from './lib/utils/assets'
|
|
export {
|
|
checkFlag,
|
|
fileToBase64,
|
|
getIncrementedName,
|
|
isSerializable,
|
|
snapToGrid,
|
|
uniqueId,
|
|
} from './lib/utils/data'
|
|
export { debugFlags, featureFlags, type DebugFlag } from './lib/utils/debug-flags'
|
|
export {
|
|
loopToHtmlElement,
|
|
preventDefault,
|
|
releasePointerCapture,
|
|
rotateBoxShadow,
|
|
setPointerCapture,
|
|
truncateStringWithEllipsis,
|
|
usePrefersReducedMotion,
|
|
} from './lib/utils/dom'
|
|
export {
|
|
getEmbedInfo,
|
|
getEmbedInfoUnsafely,
|
|
matchEmbedUrl,
|
|
matchUrl,
|
|
type TLEmbedResult,
|
|
} from './lib/utils/embeds'
|
|
export {
|
|
downloadDataURLAsFile,
|
|
getSvgAsDataUrl,
|
|
getSvgAsDataUrlSync,
|
|
getSvgAsImage,
|
|
getSvgAsString,
|
|
getTextBoundingBox,
|
|
isGeoShape,
|
|
isNoteShape,
|
|
type TLCopyType,
|
|
type TLExportType,
|
|
} from './lib/utils/export'
|
|
export { hardResetEditor } from './lib/utils/hard-reset'
|
|
export { isAnimated, isGIF } from './lib/utils/is-gif-animated'
|
|
export { setPropsForNextShape } from './lib/utils/props-for-next-shape'
|
|
export { refreshPage } from './lib/utils/refresh-page'
|
|
export { runtime, setRuntimeOverrides } from './lib/utils/runtime'
|
|
export {
|
|
blobAsString,
|
|
correctSpacesToNbsp,
|
|
dataTransferItemAsString,
|
|
defaultEmptyAs,
|
|
} from './lib/utils/string'
|
|
export { getPointerInfo, getSvgPathFromStroke, getSvgPathFromStrokePoints } from './lib/utils/svg'
|
|
export { type TLStoreWithStatus } from './lib/utils/sync/StoreWithStatus'
|
|
export { hardReset } from './lib/utils/sync/hardReset'
|
|
export { openWindow } from './lib/utils/window-open'
|