2023-04-25 11:01:25 +00:00
|
|
|
// 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
|
|
|
|
|
2023-06-04 10:38:53 +00:00
|
|
|
// eslint-disable-next-line local/no-export-star
|
|
|
|
export * from '@tldraw/indices'
|
2023-04-25 11:01:25 +00:00
|
|
|
// 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'
|
2023-06-04 10:38:53 +00:00
|
|
|
export { Editor, type TLAnimationOptions, type TLEditorOptions } from './lib/app/Editor'
|
|
|
|
export { ArrowShapeUtil } from './lib/app/shapeutils/ArrowShapeUtil/ArrowShapeUtil'
|
|
|
|
export { BaseBoxShapeUtil, type TLBaseBoxShape } from './lib/app/shapeutils/BaseBoxShapeUtil'
|
|
|
|
export { BookmarkShapeUtil } from './lib/app/shapeutils/BookmarkShapeUtil/BookmarkShapeUtil'
|
|
|
|
export { DrawShapeUtil } from './lib/app/shapeutils/DrawShapeUtil/DrawShapeUtil'
|
|
|
|
export { EmbedShapeUtil } from './lib/app/shapeutils/EmbedShapeUtil/EmbedShapeUtil'
|
|
|
|
export { FrameShapeUtil } from './lib/app/shapeutils/FrameShapeUtil/FrameShapeUtil'
|
|
|
|
export { GeoShapeUtil } from './lib/app/shapeutils/GeoShapeUtil/GeoShapeUtil'
|
|
|
|
export { GroupShapeUtil } from './lib/app/shapeutils/GroupShapeUtil/GroupShapeUtil'
|
|
|
|
export { HighlightShapeUtil } from './lib/app/shapeutils/HighlightShapeUtil/HighlightShapeUtil'
|
|
|
|
export { ImageShapeUtil } from './lib/app/shapeutils/ImageShapeUtil/ImageShapeUtil'
|
|
|
|
export {
|
|
|
|
LineShapeUtil,
|
|
|
|
getSplineForLineShape,
|
|
|
|
} from './lib/app/shapeutils/LineShapeUtil/LineShapeUtil'
|
|
|
|
export { NoteShapeUtil } from './lib/app/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,
|
add docs for TLShapeUtil (#1215)
This PR adds docs for the methods in the TLShapeUtil class.
I think that it's a good page to have docs on, as it shows people what's
possible with the custom shape API.
Currently, our docs are not showing `@param` info for lots of methods,
including the ones added in this PR.
I'll do fix for that in a follow-up PR, so that it's easier to review.
---
Note: Moving forward, we probably want to consider **_where_** these
docs are shown, and how we achieve that.
For example, do we put the docs for these methods in:
* The docs page for the `TLShapeUtil` class?
* The docs pages for the handler types, eg:
[`OnResizeHandler`](http://localhost:3000/gen/editor/OnResizeHandler-type)?
* Both?
Right now, I opted for putting them in the the TLShapeUtil class, as it
keeps them all in one place, and it's what we already do for some
others.
We should consider both - what works best for the docs? and what works
best for code editors?
---
This PR also includes a fix to our pre-commit step that @SomeHats did.
2023-05-05 14:05:25 +00:00
|
|
|
type TLResizeInfo,
|
2023-04-25 11:01:25 +00:00
|
|
|
type TLResizeMode,
|
|
|
|
type TLShapeUtilConstructor,
|
|
|
|
type TLShapeUtilFlag,
|
2023-06-04 10:38:53 +00:00
|
|
|
} from './lib/app/shapeutils/ShapeUtil'
|
|
|
|
export { INDENT, TextShapeUtil } from './lib/app/shapeutils/TextShapeUtil/TextShapeUtil'
|
|
|
|
export { VideoShapeUtil } from './lib/app/shapeutils/VideoShapeUtil/VideoShapeUtil'
|
|
|
|
export { BaseBoxShapeTool } from './lib/app/tools/BaseBoxShapeTool/BaseBoxShapeTool'
|
|
|
|
export { StateNode, type TLStateNodeConstructor } from './lib/app/tools/StateNode'
|
|
|
|
export { type TLContent } from './lib/app/types/clipboard-types'
|
2023-05-11 22:14:58 +00:00
|
|
|
export { type TLEventMap, type TLEventMapHandler } from './lib/app/types/emit-types'
|
2023-04-25 11:01:25 +00:00
|
|
|
export {
|
|
|
|
EVENT_NAME_MAP,
|
|
|
|
type TLBaseEventInfo,
|
|
|
|
type TLCLickEventName,
|
|
|
|
type TLCancelEvent,
|
|
|
|
type TLCancelEventInfo,
|
|
|
|
type TLClickEvent,
|
|
|
|
type TLClickEventInfo,
|
|
|
|
type TLCompleteEvent,
|
|
|
|
type TLCompleteEventInfo,
|
2023-06-04 10:38:53 +00:00
|
|
|
type TLEnterEventHandler,
|
2023-04-25 11:01:25 +00:00
|
|
|
type TLEventHandlers,
|
|
|
|
type TLEventInfo,
|
|
|
|
type TLEventName,
|
2023-06-04 10:38:53 +00:00
|
|
|
type TLExitEventHandler,
|
2023-04-25 11:01:25 +00:00
|
|
|
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/app/types/event-types'
|
|
|
|
export {
|
|
|
|
type TLCommand,
|
|
|
|
type TLCommandHandler,
|
|
|
|
type TLHistoryEntry,
|
2023-06-04 10:38:53 +00:00
|
|
|
type TLHistoryMark,
|
2023-04-25 11:01:25 +00:00
|
|
|
} from './lib/app/types/history-types'
|
2023-06-04 10:38:53 +00:00
|
|
|
export { type RequiredKeys } from './lib/app/types/misc-types'
|
2023-04-25 11:01:25 +00:00
|
|
|
export { type TLResizeHandle, type TLSelectionHandle } from './lib/app/types/selection-types'
|
2023-05-05 13:10:36 +00:00
|
|
|
export {
|
|
|
|
defaultEditorAssetUrls,
|
|
|
|
setDefaultEditorAssetUrls,
|
2023-06-04 10:38:53 +00:00
|
|
|
type TLEditorAssetUrls,
|
2023-05-05 13:10:36 +00:00
|
|
|
} from './lib/assetUrls'
|
2023-04-25 11:01:25 +00:00
|
|
|
export { Canvas } from './lib/components/Canvas'
|
|
|
|
export { DefaultErrorFallback } from './lib/components/DefaultErrorFallback'
|
|
|
|
export {
|
|
|
|
ErrorBoundary,
|
|
|
|
OptionalErrorBoundary,
|
2023-06-04 10:38:53 +00:00
|
|
|
type TLErrorBoundaryProps,
|
2023-04-25 11:01:25 +00:00
|
|
|
} from './lib/components/ErrorBoundary'
|
|
|
|
export { HTMLContainer, type HTMLContainerProps } from './lib/components/HTMLContainer'
|
|
|
|
export { SVGContainer, type SVGContainerProps } from './lib/components/SVGContainer'
|
|
|
|
export {
|
[refactor] User-facing APIs (#1478)
This PR updates our user-facing APIs for the Tldraw and TldrawEditor
components, as well as the Editor (App). It mainly incorporates surface
changes from #1450 without any changes to validators or migrators,
incorporating feedback / discussion with @SomeHats and @ds300.
Here we:
- remove the TldrawEditorConfig
- bring back a loose version of shape definitions
- make a separation between "core" shapes and "default" shapes
- do not allow custom shapes, migrators or validators to overwrite core
shapes
- but _do_ allow new shapes
## `<Tldraw>` component
In this PR, the `Tldraw` component wraps both the `TldrawEditor`
component and our `TldrawUi` component. It accepts a union of props for
both components. Previously, this component also added local syncing via
a `useLocalSyncClient` hook call, however that has been pushed down to
the `TldrawEditor` component.
## `<TldrawEditor>` component
The `TldrawEditor` component now more neatly wraps up the different ways
that the editor can be configured.
## The store prop (`TldrawEditorProps.store`)
There are three main ways for the `TldrawEditor` component to be run:
1. with an externally defined store
2. with an externally defined syncing store (local or remote)
3. with an internally defined store
4. with an internally defined locally syncing store
The `store` prop allows for these configurations.
If the `store` prop is defined, it may be defined either as a `TLStore`
or as a `SyncedStore`. If the store is a `TLStore`, then the Editor will
assume that the store is ready to go; if it is defined as a SyncedStore,
then the component will display the loading / error screens as needed,
or the final editor once the store's status is "synced".
When the store is left undefined, then the `TldrawEditor` will create
its own internal store using the optional `instanceId`, `initialData`,
or `shapes` props to define the store / store schema.
If the `persistenceKey` prop is left undefined, then the store will not
be synced. If the `persistenceKey` is defined, then the store will be
synced locally. In the future, we may also here accept the API key /
roomId / etc for creating a remotely synced store.
The `SyncedStore` type has been expanded to also include types used for
remote syncing, e.g. with `ConnectionStatus`.
## Tools
By default, the App has two "baked-in" tools: the select tool and the
zoom tool. These cannot (for now) be replaced or removed. The default
tools are used by default, but may be replaced by other tools if
provided.
## Shapes
By default, the App has a set of "core" shapes:
- group
- embed
- bookmark
- image
- video
- text
That cannot by overwritten because they're created by the app at
different moments, such as when double clicking on the canvas or via a
copy and paste event. In follow up PRs, we'll split these out so that
users can replace parts of the code where these shapes are created.
### Change Type
- [x] `major` — Breaking Change
### Test Plan
- [x] Unit Tests
2023-06-01 15:47:34 +00:00
|
|
|
USER_COLORS,
|
|
|
|
getUserPreferences,
|
|
|
|
setUserPreferences,
|
|
|
|
type TLUserPreferences,
|
|
|
|
} from './lib/config/TLUserPreferences'
|
|
|
|
export { createTLStore } from './lib/config/createTLStore'
|
|
|
|
export { defaultShapes } from './lib/config/defaultShapes'
|
|
|
|
export { defaultTools } from './lib/config/defaultTools'
|
2023-04-25 11:01:25 +00:00
|
|
|
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 { normalizeWheel } from './lib/hooks/shared'
|
|
|
|
export { useContainer } from './lib/hooks/useContainer'
|
2023-06-02 15:21:45 +00:00
|
|
|
export { useEditor } from './lib/hooks/useEditor'
|
2023-04-25 11:01:25 +00:00
|
|
|
export type { TLEditorComponents } from './lib/hooks/useEditorComponents'
|
[refactor] User-facing APIs (#1478)
This PR updates our user-facing APIs for the Tldraw and TldrawEditor
components, as well as the Editor (App). It mainly incorporates surface
changes from #1450 without any changes to validators or migrators,
incorporating feedback / discussion with @SomeHats and @ds300.
Here we:
- remove the TldrawEditorConfig
- bring back a loose version of shape definitions
- make a separation between "core" shapes and "default" shapes
- do not allow custom shapes, migrators or validators to overwrite core
shapes
- but _do_ allow new shapes
## `<Tldraw>` component
In this PR, the `Tldraw` component wraps both the `TldrawEditor`
component and our `TldrawUi` component. It accepts a union of props for
both components. Previously, this component also added local syncing via
a `useLocalSyncClient` hook call, however that has been pushed down to
the `TldrawEditor` component.
## `<TldrawEditor>` component
The `TldrawEditor` component now more neatly wraps up the different ways
that the editor can be configured.
## The store prop (`TldrawEditorProps.store`)
There are three main ways for the `TldrawEditor` component to be run:
1. with an externally defined store
2. with an externally defined syncing store (local or remote)
3. with an internally defined store
4. with an internally defined locally syncing store
The `store` prop allows for these configurations.
If the `store` prop is defined, it may be defined either as a `TLStore`
or as a `SyncedStore`. If the store is a `TLStore`, then the Editor will
assume that the store is ready to go; if it is defined as a SyncedStore,
then the component will display the loading / error screens as needed,
or the final editor once the store's status is "synced".
When the store is left undefined, then the `TldrawEditor` will create
its own internal store using the optional `instanceId`, `initialData`,
or `shapes` props to define the store / store schema.
If the `persistenceKey` prop is left undefined, then the store will not
be synced. If the `persistenceKey` is defined, then the store will be
synced locally. In the future, we may also here accept the API key /
roomId / etc for creating a remotely synced store.
The `SyncedStore` type has been expanded to also include types used for
remote syncing, e.g. with `ConnectionStatus`.
## Tools
By default, the App has two "baked-in" tools: the select tool and the
zoom tool. These cannot (for now) be replaced or removed. The default
tools are used by default, but may be replaced by other tools if
provided.
## Shapes
By default, the App has a set of "core" shapes:
- group
- embed
- bookmark
- image
- video
- text
That cannot by overwritten because they're created by the app at
different moments, such as when double clicking on the canvas or via a
copy and paste event. In follow up PRs, we'll split these out so that
users can replace parts of the code where these shapes are created.
### Change Type
- [x] `major` — Breaking Change
### Test Plan
- [x] Unit Tests
2023-06-01 15:47:34 +00:00
|
|
|
export { useLocalStore } from './lib/hooks/useLocalStore'
|
2023-05-03 13:48:46 +00:00
|
|
|
export { usePeerIds } from './lib/hooks/usePeerIds'
|
|
|
|
export { usePresence } from './lib/hooks/usePresence'
|
2023-04-25 11:01:25 +00:00
|
|
|
export { useQuickReactor } from './lib/hooks/useQuickReactor'
|
|
|
|
export { useReactor } from './lib/hooks/useReactor'
|
[refactor] User-facing APIs (#1478)
This PR updates our user-facing APIs for the Tldraw and TldrawEditor
components, as well as the Editor (App). It mainly incorporates surface
changes from #1450 without any changes to validators or migrators,
incorporating feedback / discussion with @SomeHats and @ds300.
Here we:
- remove the TldrawEditorConfig
- bring back a loose version of shape definitions
- make a separation between "core" shapes and "default" shapes
- do not allow custom shapes, migrators or validators to overwrite core
shapes
- but _do_ allow new shapes
## `<Tldraw>` component
In this PR, the `Tldraw` component wraps both the `TldrawEditor`
component and our `TldrawUi` component. It accepts a union of props for
both components. Previously, this component also added local syncing via
a `useLocalSyncClient` hook call, however that has been pushed down to
the `TldrawEditor` component.
## `<TldrawEditor>` component
The `TldrawEditor` component now more neatly wraps up the different ways
that the editor can be configured.
## The store prop (`TldrawEditorProps.store`)
There are three main ways for the `TldrawEditor` component to be run:
1. with an externally defined store
2. with an externally defined syncing store (local or remote)
3. with an internally defined store
4. with an internally defined locally syncing store
The `store` prop allows for these configurations.
If the `store` prop is defined, it may be defined either as a `TLStore`
or as a `SyncedStore`. If the store is a `TLStore`, then the Editor will
assume that the store is ready to go; if it is defined as a SyncedStore,
then the component will display the loading / error screens as needed,
or the final editor once the store's status is "synced".
When the store is left undefined, then the `TldrawEditor` will create
its own internal store using the optional `instanceId`, `initialData`,
or `shapes` props to define the store / store schema.
If the `persistenceKey` prop is left undefined, then the store will not
be synced. If the `persistenceKey` is defined, then the store will be
synced locally. In the future, we may also here accept the API key /
roomId / etc for creating a remotely synced store.
The `SyncedStore` type has been expanded to also include types used for
remote syncing, e.g. with `ConnectionStatus`.
## Tools
By default, the App has two "baked-in" tools: the select tool and the
zoom tool. These cannot (for now) be replaced or removed. The default
tools are used by default, but may be replaced by other tools if
provided.
## Shapes
By default, the App has a set of "core" shapes:
- group
- embed
- bookmark
- image
- video
- text
That cannot by overwritten because they're created by the app at
different moments, such as when double clicking on the canvas or via a
copy and paste event. In follow up PRs, we'll split these out so that
users can replace parts of the code where these shapes are created.
### Change Type
- [x] `major` — Breaking Change
### Test Plan
- [x] Unit Tests
2023-06-01 15:47:34 +00:00
|
|
|
export { useTLStore } from './lib/hooks/useTLStore'
|
2023-04-25 11:01:25 +00:00
|
|
|
export { WeakMapCache } from './lib/utils/WeakMapCache'
|
|
|
|
export {
|
|
|
|
ACCEPTED_ASSET_TYPE,
|
|
|
|
ACCEPTED_IMG_TYPE,
|
|
|
|
ACCEPTED_VID_TYPE,
|
|
|
|
containBoxSize,
|
|
|
|
createAssetShapeAtPoint,
|
|
|
|
createBookmarkShapeAtPoint,
|
|
|
|
createEmbedShapeAtPoint,
|
|
|
|
createShapesFromFiles,
|
|
|
|
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'
|
Feature flags rework (#1474)
This diff tweaks our `debugFlags` framework to support setting different
default value for different environments, makes it easier to define
feature flags, and makes feature flags show up in the debug menu by
default. With this change, feature flags will default to being enabled
in dev and preview environments, but disabled in production.
Specify a feature flag like this:
```ts
const featureFlags = {
myCoolNewFeature: createFeatureFlag('myCoolNewFeature')
}
```
optionally, pass a second value to control its defaults:
```ts
const featureFlags = {
featureEnabledInProduction: createFeatureFlag('someFeature', { all: true }),
customEnabled: createFeatureFlag('otherFeature', {development: true, staging: false, production: false}),
}
```
In code, the value can be read using `featureFlags.myFeature.value`.
Remember to wrap reading it in a reactive context!
### Change Type
- [x] `patch` — Bug Fix
### Test Plan
-
### Release Notes
[internal only change]
2023-05-30 13:06:15 +00:00
|
|
|
export { debugFlags, featureFlags, type DebugFlag } from './lib/utils/debug-flags'
|
2023-04-25 11:01:25 +00:00
|
|
|
export {
|
|
|
|
loopToHtmlElement,
|
|
|
|
preventDefault,
|
|
|
|
releasePointerCapture,
|
|
|
|
rotateBoxShadow,
|
|
|
|
setPointerCapture,
|
|
|
|
truncateStringWithEllipsis,
|
|
|
|
usePrefersReducedMotion,
|
|
|
|
} from './lib/utils/dom'
|
|
|
|
export {
|
|
|
|
getEmbedInfo,
|
|
|
|
getEmbedInfoUnsafely,
|
|
|
|
matchEmbedUrl,
|
|
|
|
matchUrl,
|
2023-06-04 10:38:53 +00:00
|
|
|
type TLEmbedResult,
|
2023-04-25 11:01:25 +00:00
|
|
|
} from './lib/utils/embeds'
|
|
|
|
export {
|
|
|
|
downloadDataURLAsFile,
|
|
|
|
getSvgAsDataUrl,
|
|
|
|
getSvgAsDataUrlSync,
|
|
|
|
getSvgAsImage,
|
|
|
|
getSvgAsString,
|
|
|
|
getTextBoundingBox,
|
|
|
|
isGeoShape,
|
|
|
|
isNoteShape,
|
|
|
|
type TLCopyType,
|
|
|
|
type TLExportType,
|
|
|
|
} from './lib/utils/export'
|
2023-06-02 15:21:45 +00:00
|
|
|
export { hardResetEditor } from './lib/utils/hard-reset'
|
2023-04-25 11:01:25 +00:00
|
|
|
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'
|
2023-06-04 10:38:53 +00:00
|
|
|
export { type TLStoreWithStatus } from './lib/utils/sync/StoreWithStatus'
|
[refactor] User-facing APIs (#1478)
This PR updates our user-facing APIs for the Tldraw and TldrawEditor
components, as well as the Editor (App). It mainly incorporates surface
changes from #1450 without any changes to validators or migrators,
incorporating feedback / discussion with @SomeHats and @ds300.
Here we:
- remove the TldrawEditorConfig
- bring back a loose version of shape definitions
- make a separation between "core" shapes and "default" shapes
- do not allow custom shapes, migrators or validators to overwrite core
shapes
- but _do_ allow new shapes
## `<Tldraw>` component
In this PR, the `Tldraw` component wraps both the `TldrawEditor`
component and our `TldrawUi` component. It accepts a union of props for
both components. Previously, this component also added local syncing via
a `useLocalSyncClient` hook call, however that has been pushed down to
the `TldrawEditor` component.
## `<TldrawEditor>` component
The `TldrawEditor` component now more neatly wraps up the different ways
that the editor can be configured.
## The store prop (`TldrawEditorProps.store`)
There are three main ways for the `TldrawEditor` component to be run:
1. with an externally defined store
2. with an externally defined syncing store (local or remote)
3. with an internally defined store
4. with an internally defined locally syncing store
The `store` prop allows for these configurations.
If the `store` prop is defined, it may be defined either as a `TLStore`
or as a `SyncedStore`. If the store is a `TLStore`, then the Editor will
assume that the store is ready to go; if it is defined as a SyncedStore,
then the component will display the loading / error screens as needed,
or the final editor once the store's status is "synced".
When the store is left undefined, then the `TldrawEditor` will create
its own internal store using the optional `instanceId`, `initialData`,
or `shapes` props to define the store / store schema.
If the `persistenceKey` prop is left undefined, then the store will not
be synced. If the `persistenceKey` is defined, then the store will be
synced locally. In the future, we may also here accept the API key /
roomId / etc for creating a remotely synced store.
The `SyncedStore` type has been expanded to also include types used for
remote syncing, e.g. with `ConnectionStatus`.
## Tools
By default, the App has two "baked-in" tools: the select tool and the
zoom tool. These cannot (for now) be replaced or removed. The default
tools are used by default, but may be replaced by other tools if
provided.
## Shapes
By default, the App has a set of "core" shapes:
- group
- embed
- bookmark
- image
- video
- text
That cannot by overwritten because they're created by the app at
different moments, such as when double clicking on the canvas or via a
copy and paste event. In follow up PRs, we'll split these out so that
users can replace parts of the code where these shapes are created.
### Change Type
- [x] `major` — Breaking Change
### Test Plan
- [x] Unit Tests
2023-06-01 15:47:34 +00:00
|
|
|
export { hardReset } from './lib/utils/sync/hardReset'
|
|
|
|
export { TAB_ID } from './lib/utils/sync/persistence-constants'
|
2023-04-25 11:01:25 +00:00
|
|
|
export { openWindow } from './lib/utils/window-open'
|