@ibodr/editor 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +15 -8
- package/dist/index.mjs +258 -42
- package/dist/index.mjs.map +1 -1
- package/editor.css +32 -0
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as _ibodr_store from '@ibodr/store';
|
|
|
6
6
|
import { LegacyMigrations, MigrationSequence, UnknownRecord, SerializedSchema, RecordsDiff, Store, AtomSet, HistoryEntry, StoreSideEffects, SerializedStore, StoreSchema } from '@ibodr/store';
|
|
7
7
|
export * from '@ibodr/store';
|
|
8
8
|
import * as _ibodr_schema from '@ibodr/schema';
|
|
9
|
-
import { DrAsset, RecordProps, DrPropsMigrations, DrUnknownAsset, DrAssetId, DrBinding, DrUnknownBinding, DrShape, VecModel, BoxModel, DrHandle, DrShapeId, DrCursorType, DrUnknownShape, DrShapePartial, DrFontFace, DrShapeCrop, DrParentId, DrGroupShape, DrPageId, DrStore, DrStoreSnapshot, DrUser, DrRichText, StyleProp, DrInstancePresence, DrScribble, DrDefaultHorizontalAlignStyle, DrRecord, DrThemes, DrThemeId, DrTheme, DrInstancePageState, DrInstance, DrDocument, DrCursor, DrCamera, DrPage, DrImageAsset, DrVideoAsset, DrAssetPartial, DrBindingId, DrBindingCreate, DrBindingUpdate, DrCreateShapePartial, StylePropValue, DrAssetStore, DrUserStore, DrStoreProps, CustomRecordInfo, DrThemeColors, DrDefaultColorStyle, DrDefaultColor, ExtractShapeByProps, DrDefaultDashStyle, DrBaseShape, DrStoreSchema } from '@ibodr/schema';
|
|
9
|
+
import { DrAsset, RecordProps, DrPropsMigrations, DrUnknownAsset, DrAssetId, DrBinding, DrUnknownBinding, DrShape, VecModel, BoxModel, DrHandle, DrShapeId, DrCursorType, DrUnknownShape, DrShapePartial, DrFontFace, DrShapeCrop, DrParentId, DrGroupShape, DrPageId, DrBoardBackgroundType, DrStore, DrStoreSnapshot, DrUser, DrRichText, StyleProp, DrInstancePresence, DrScribble, DrDefaultHorizontalAlignStyle, DrRecord, DrThemes, DrThemeId, DrTheme, DrInstancePageState, DrInstance, DrDocument, DrCursor, DrCamera, DrPage, DrImageAsset, DrVideoAsset, DrAssetPartial, DrBindingId, DrBindingCreate, DrBindingUpdate, DrCreateShapePartial, StylePropValue, DrAssetStore, DrUserStore, DrStoreProps, CustomRecordInfo, DrThemeColors, DrDefaultColorStyle, DrDefaultColor, ExtractShapeByProps, DrDefaultDashStyle, DrBaseShape, DrStoreSchema } from '@ibodr/schema';
|
|
10
10
|
export * from '@ibodr/schema';
|
|
11
11
|
import { IndexKey, Awaitable, PerformanceTracker, JsonObject, Timers } from '@ibodr/utils';
|
|
12
12
|
export * from '@ibodr/utils';
|
|
@@ -20,8 +20,14 @@ import { Editor as Editor$1 } from '@tiptap/core';
|
|
|
20
20
|
import { Node as Node$1 } from '@tiptap/pm/model';
|
|
21
21
|
import { EditorProviderProps as EditorProviderProps$1 } from '@tiptap/react';
|
|
22
22
|
|
|
23
|
+
/** @public */
|
|
24
|
+
interface DrBackgroundProps {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
z: number;
|
|
28
|
+
}
|
|
23
29
|
/** @public @react */
|
|
24
|
-
declare function DefaultBackground(): react_jsx_runtime.JSX.Element;
|
|
30
|
+
declare function DefaultBackground({ x, y, z }: DrBackgroundProps): react_jsx_runtime.JSX.Element;
|
|
25
31
|
|
|
26
32
|
/** @public */
|
|
27
33
|
interface DrCanvasComponentProps {
|
|
@@ -2258,6 +2264,7 @@ interface DrSessionStateSnapshot {
|
|
|
2258
2264
|
isDebugMode?: boolean;
|
|
2259
2265
|
isToolLocked?: boolean;
|
|
2260
2266
|
isGridMode?: boolean;
|
|
2267
|
+
backgroundType?: DrBoardBackgroundType;
|
|
2261
2268
|
pageStates?: Array<{
|
|
2262
2269
|
pageId: DrPageId;
|
|
2263
2270
|
camera?: {
|
|
@@ -4168,7 +4175,7 @@ declare class UserPreferencesManager {
|
|
|
4168
4175
|
isWrapMode: boolean;
|
|
4169
4176
|
isDynamicResizeMode: boolean;
|
|
4170
4177
|
enhancedA11yMode: boolean;
|
|
4171
|
-
inputMode: "
|
|
4178
|
+
inputMode: "trackpad" | "mouse" | null;
|
|
4172
4179
|
isZoomDirectionInverted: boolean;
|
|
4173
4180
|
};
|
|
4174
4181
|
getIsDarkMode(): boolean;
|
|
@@ -4187,7 +4194,7 @@ declare class UserPreferencesManager {
|
|
|
4187
4194
|
getIsDynamicResizeMode(): boolean;
|
|
4188
4195
|
getIsPasteAtCursorMode(): boolean;
|
|
4189
4196
|
getEnhancedA11yMode(): boolean;
|
|
4190
|
-
getInputMode(): "
|
|
4197
|
+
getInputMode(): "trackpad" | "mouse" | null;
|
|
4191
4198
|
getIsZoomDirectionInverted(): boolean;
|
|
4192
4199
|
}
|
|
4193
4200
|
|
|
@@ -8352,12 +8359,12 @@ declare class ErrorBoundary extends React$1.Component<React$1.PropsWithChildren<
|
|
|
8352
8359
|
error: null;
|
|
8353
8360
|
};
|
|
8354
8361
|
componentDidCatch(error: unknown): void;
|
|
8355
|
-
render(): string | number | bigint | boolean |
|
|
8362
|
+
render(): string | number | bigint | boolean | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
8356
8363
|
}
|
|
8357
8364
|
/** @internal */
|
|
8358
8365
|
declare function OptionalErrorBoundary({ children, fallback, ...props }: Omit<DrErrorBoundaryProps, 'fallback'> & {
|
|
8359
8366
|
fallback: DrErrorFallbackComponent;
|
|
8360
|
-
}): string | number | bigint | boolean |
|
|
8367
|
+
}): string | number | bigint | boolean | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
8361
8368
|
|
|
8362
8369
|
/** @public */
|
|
8363
8370
|
type HTMLContainerProps = React$1.HTMLAttributes<HTMLDivElement>;
|
|
@@ -9093,7 +9100,7 @@ interface DrCollaboratorCursorProps {
|
|
|
9093
9100
|
|
|
9094
9101
|
/** @public */
|
|
9095
9102
|
interface DrEditorComponents {
|
|
9096
|
-
Background?: ComponentType | null;
|
|
9103
|
+
Background?: ComponentType<DrBackgroundProps> | null;
|
|
9097
9104
|
Canvas?: ComponentType<DrCanvasComponentProps> | null;
|
|
9098
9105
|
Grid?: ComponentType<DrGridProps> | null;
|
|
9099
9106
|
/** Renders a single collaborator cursor. Pass `null` to hide cursors entirely. */
|
|
@@ -10426,4 +10433,4 @@ declare function uniq<T>(array: {
|
|
|
10426
10433
|
readonly [n: number]: T;
|
|
10427
10434
|
} | null | undefined): T[];
|
|
10428
10435
|
|
|
10429
|
-
export { Arc2d, AssetUtil, BaseBoxShapeTool, BaseBoxShapeUtil, BaseFrameLikeShapeUtil, type BatchMeasurementRequest, type BindingOnChangeOptions, type BindingOnCreateOptions, type BindingOnDeleteOptions, type BindingOnShapeChangeOptions, type BindingOnShapeDeleteOptions, type BindingOnShapeIsolateOptions, BindingUtil, type BoundsSnapGeometry, type BoundsSnapPoint, BoundsSnaps, Box, type BoxLike, type CanvasMaxSize, Circle2d, ClickManager, CollaboratorsManager, ContainerProvider, type ContainerProviderProps, CubicBezier2d, CubicSpline2d, DEFAULT_ANIMATION_OPTIONS, DEFAULT_CAMERA_OPTIONS, DEFAULT_THEME, type DebugFlag, type DebugFlagDef, type DebugFlagDefaults, DefaultBackground, DefaultCanvas, DefaultErrorFallback, DefaultGrid, DefaultSelectionBackground, DefaultShapeWrapper, DefaultSpinner, DefaultSvgDefs, type DrAdjacentDirection, type DrAnyAssetUtilConstructor, type DrAnyBindingUtilConstructor, type DrAnyOverlayUtilConstructor, type DrAnyShapeUtilConstructor, type DrAssetUtilConstructor, type DrBaseBoxShape, type DrBaseEventInfo, type DrBaseExternalContent, type DrBindingUtilConstructor, type DrCLickEventName, type DrCameraConstraints, type DrCameraEndPerfEvent, type DrCameraMoveOptions, type DrCameraOptions, type DrCameraStartPerfEvent, type DrCancelEvent, type DrCancelEventInfo, type DrCanvasComponentProps, type DrClickEvent, type DrClickEventInfo, type DrClickState, type DrClipboardPasteRawInfo, type DrClipboardWriteInfo, type DrCollaboratorCursorLayout, type DrCollaboratorCursorProps, type DrCompleteEvent, type DrCompleteEventInfo, type DrContent, type DrCropInfo, type DrCurrentUser, type DrDeepLink, type DrDeepLinkOptions, type DrDragShapesInInfo, type DrDragShapesOutInfo, type DrDragShapesOverInfo, type DrDrawExternalContent, type DrDrawExternalContentSource, type DrDropShapesOverInfo, type DrEditStartInfo, type DrEditorComponents, type DrEditorOptions, type DrEditorRunOptions, type DrEditorSnapshot, type DrEmbedExternalContent, type DrEnterEventHandler, type DrErrorBoundaryProps, type DrErrorExternalContentSource, type DrErrorFallbackComponent, type DrEventHandlers, type DrEventInfo, type DrEventMap, type DrEventMapHandler, type DrEventName, type DrExcalidrawExternalContent, type DrExcalidrawExternalContentSource, type DrExitEventHandler, type DrExportType, type DrExternalAsset, type DrExternalContent, type DrExternalContentSource, type DrFileExternalAsset, type DrFileReplaceExternalContent, type DrFilesExternalContent, type DrFramePerfEvent, type DrGeometryOpts, type DrGetShapeAtPointOptions, type DrGridProps, type DrHandleDragInfo, type DrHistoryBatchOptions, type DrHistoryDiff, type DrHistoryEntry, type DrHistoryMark, type DrImageExportOptions, type DrIndicatorPath, type DrInteractionEndPerfEvent, type DrInteractionStartPerfEvent, type DrInterruptEvent, type DrInterruptEventInfo, type DrKeyboardEvent, type DrKeyboardEventInfo, type DrKeyboardEventName, type DrLoadSessionStateSnapshotOptions, type DrLoadSnapshotOptions, type DrMeasureTextOpts, type DrMeasureTextSpanOpts, type DrMeasuredTextSize, type DrOnMountHandler, type DrOverlay, type DrOverlayEntry, type DrOverlayUtilConstructor, type DrPerfEventMap, type DrPerfFrameTimeStats, type DrPerfLongAnimationFrame, type DrPerfLongAnimationFrameScript, type DrPinchEvent, type DrPinchEventInfo, type DrPinchEventName, type DrPointerEvent, type DrPointerEventInfo, type DrPointerEventName, type DrPointerEventTarget, type DrRenderingShape, type DrResizeHandle, type DrResizeInfo, type DrResizeMode, type DrResizeShapeOptions, type DrRotationSnapshot, type DrSelectionBackgroundProps, type DrSelectionHandle, type DrSessionStateSnapshot, type DrShapeErrorFallbackComponent, type DrShapeIndicatorOverlay, type DrShapeOperationPerfEvent, type DrShapeUtilCanBeLaidOutOpts, type DrShapeUtilCanBindOpts, type DrShapeUtilCanvasSvgDef, type DrShapeUtilConstructor, type DrShapeWrapperProps, type DrStateNodeConstructor, type DrStoreBaseOptions, type DrStoreEventInfo, type DrStoreOptions, type DrStoreSchemaOptions, type DrStoreWithStatus, type DrSvgExportOptions, type DrSvgTextExternalContent, type DrTextExternalContent, type DrTextExternalContentSource, type DrTextOptions, type DrTickEvent, type DrTickEventInfo, type DrUndoRedoPerfEvent, type DrUpdatePointerOptions, type DrUrlExternalAsset, type DrUrlExternalContent, type DrUserPreferences, type DrWheelEvent, type DrWheelEventInfo, DrawEditor, type DrawEditorBaseProps, type DrawEditorProps, type DrawEditorStoreProps, type DrawEditorWithStoreProps, type DrawEditorWithoutStoreProps, type DrawOptions, EASINGS, EVENT_NAME_MAP, Edge2d, EdgeScrollManager, Editor, EditorAtom, EditorContext, EditorProvider, type EditorProviderProps, Ellipse2d, ErrorBoundary, ErrorScreen, FontManager, type GapsSnapIndicator, Geometry2d, Geometry2dFilters, type Geometry2dOptions, Group2d, GroupShapeUtil, HALF_PI, HTMLContainer, type HTMLContainerProps, type HandleSnapGeometry, HandleSnaps, HistoryManager, InputsManager, LoadingScreen, type LoadingScreenProps, LocalIndexedDb, Mat, type MatLike, type MatModel, MenuClickCapture, OptionalErrorBoundary, type OptionalKeys, OverlayManager, type OverlayOptionsWithDisplayValues, OverlayUtil, PI, PI2, type PerfectDashTerminal, PerformanceApiAdapter, PerformanceManager, Point2d, type PointsSnapIndicator, Polygon2d, Polyline2d, ROTATE_CORNER_TO_SELECTION_CORNER, ReadonlySharedStyleMap, Rectangle2d, type RequiredKeys, type ResizeBoxOptions, type RichTextFontVisitor, type RichTextFontVisitorState, type RotateCorner, SIDES, SIN, SVGContainer, type SVGContainerProps, type SafeId, type ScribbleItem, ScribbleManager, type ScribbleSessionOptions, type SelectionCorner, type SelectionEdge, type SelectionHandle, ShapeIndicatorOverlayUtil, ShapeUtil, type SharedStyle, SharedStyleMap, type SnapData, type SnapIndicator, SnapManager, SpatialIndexManager, Stadium2d, StateNode, type StoreName, type SvgExportContext, type SvgExportDef, TAB_ID, Table, TextManager, ThemeManager, TickManager, type TiptapEditor, type TiptapNode, TransformedGeometry2d, type TransformedGeometry2dOptions, USER_COLORS, type UiEvent, type UiEventType, UserPreferencesManager, Vec, type VecLike, activeElementShouldCaptureKeys, angleDistance, applyRotationToSnapshotShapes, approximately, areAnglesCompatible, average, canonicalizeRotation, centerOfCircleFromThreePoints, clamp, clampRadians, clampToBrowserMaxCanvasSize, clockwiseAngleDist, coreShapes, counterClockwiseAngleDist, createDebugValue, createDeepLinkString, createDrCurrentUser, createDrSchemaFromUtils, createDrStore, createSessionStateSnapshotSignal, dataUrlToFile, debugFlags, defaultDrawOptions, defaultUserPreferences, defaultUserStore, degreesToRadians, elementShouldCaptureKeys, extractSessionStateFromLegacySnapshot, featureFlags, getArcMeasure, getColorValue, getCursor, getDefaultCdnBaseUrl, getDroppedShapesToNewParents, getFontsFromRichText, getFreshUserPreferences, getGlobalDocument, getGlobalWindow, getIncrementedName, getOverlayDisplayValues, getOwnerDocument, getOwnerWindow, getPerfectDashProps, getPointInArcT, getPointOnCircle, getPointerInfo, getPointsOnArc, getPolygonVertices, getRotationSnapshot, getSnapshot, getSvgAsImage, getSvgPathFromPoints, getUserPreferences, getVerticesCountForArcLength, hardReset, hardResetEditor, inlineBase64AssetStore, intersectCircleCircle, intersectCirclePolygon, intersectCirclePolyline, intersectLineSegmentCircle, intersectLineSegmentLineSegment, intersectLineSegmentPolygon, intersectLineSegmentPolyline, intersectPolygonBounds, intersectPolygonPolygon, isAccelKey, isSafeFloat, kickoutOccludedShapes, linesIntersect, loadSessionStateSnapshotIntoStore, loadSnapshot, loopToHtmlElement, maybeSnapToGrid, normalizeWheel, openWindow, parseDeepLinkString, perimeterOfEllipse, pointInPolygon, polygonIntersectsPolyline, polygonsIntersect, precise, preventDefault, radiansToDegrees, rangeIntersection, refreshPage, releasePointerCapture, resizeBox, resizeScaled, resolveThemes, rotateSelectionHandle, runtime, sanitizeId, setPointerCapture, setRuntimeOverrides, setUserPreferences, shortAngleDist, snapAngle, stopEventPropagation, strokeShapeIndicators, suffixSafeId, tlenv, tlenvReactive, tlmenus, tltime, toDomPrecision, toFixed, toPrecision, uniq, useColorMode, useContainer, useContainerIfExists, useDelaySvgExport, useDrSchemaFromUtils, useDrStore, useDrawCurrentUser, useEditor, useEditorComponents, useEvent, useGlobalMenuIsOpen, useIsCropping, useIsEditing, useLocalStore, useMaybeEditor, useOnMount, usePassThroughMouseOverEvents, usePassThroughWheelEvents, usePeerIds, usePresence, useReactiveEvent, useRefState, useShallowArrayIdentity, useShallowObjectIdentity, useSharedSafeId, useSvgExportContext, useTransform, useUniqueSafeId, useViewportHeight, userTypeValidator };
|
|
10436
|
+
export { Arc2d, AssetUtil, BaseBoxShapeTool, BaseBoxShapeUtil, BaseFrameLikeShapeUtil, type BatchMeasurementRequest, type BindingOnChangeOptions, type BindingOnCreateOptions, type BindingOnDeleteOptions, type BindingOnShapeChangeOptions, type BindingOnShapeDeleteOptions, type BindingOnShapeIsolateOptions, BindingUtil, type BoundsSnapGeometry, type BoundsSnapPoint, BoundsSnaps, Box, type BoxLike, type CanvasMaxSize, Circle2d, ClickManager, CollaboratorsManager, ContainerProvider, type ContainerProviderProps, CubicBezier2d, CubicSpline2d, DEFAULT_ANIMATION_OPTIONS, DEFAULT_CAMERA_OPTIONS, DEFAULT_THEME, type DebugFlag, type DebugFlagDef, type DebugFlagDefaults, DefaultBackground, DefaultCanvas, DefaultErrorFallback, DefaultGrid, DefaultSelectionBackground, DefaultShapeWrapper, DefaultSpinner, DefaultSvgDefs, type DrAdjacentDirection, type DrAnyAssetUtilConstructor, type DrAnyBindingUtilConstructor, type DrAnyOverlayUtilConstructor, type DrAnyShapeUtilConstructor, type DrAssetUtilConstructor, type DrBackgroundProps, type DrBaseBoxShape, type DrBaseEventInfo, type DrBaseExternalContent, type DrBindingUtilConstructor, type DrCLickEventName, type DrCameraConstraints, type DrCameraEndPerfEvent, type DrCameraMoveOptions, type DrCameraOptions, type DrCameraStartPerfEvent, type DrCancelEvent, type DrCancelEventInfo, type DrCanvasComponentProps, type DrClickEvent, type DrClickEventInfo, type DrClickState, type DrClipboardPasteRawInfo, type DrClipboardWriteInfo, type DrCollaboratorCursorLayout, type DrCollaboratorCursorProps, type DrCompleteEvent, type DrCompleteEventInfo, type DrContent, type DrCropInfo, type DrCurrentUser, type DrDeepLink, type DrDeepLinkOptions, type DrDragShapesInInfo, type DrDragShapesOutInfo, type DrDragShapesOverInfo, type DrDrawExternalContent, type DrDrawExternalContentSource, type DrDropShapesOverInfo, type DrEditStartInfo, type DrEditorComponents, type DrEditorOptions, type DrEditorRunOptions, type DrEditorSnapshot, type DrEmbedExternalContent, type DrEnterEventHandler, type DrErrorBoundaryProps, type DrErrorExternalContentSource, type DrErrorFallbackComponent, type DrEventHandlers, type DrEventInfo, type DrEventMap, type DrEventMapHandler, type DrEventName, type DrExcalidrawExternalContent, type DrExcalidrawExternalContentSource, type DrExitEventHandler, type DrExportType, type DrExternalAsset, type DrExternalContent, type DrExternalContentSource, type DrFileExternalAsset, type DrFileReplaceExternalContent, type DrFilesExternalContent, type DrFramePerfEvent, type DrGeometryOpts, type DrGetShapeAtPointOptions, type DrGridProps, type DrHandleDragInfo, type DrHistoryBatchOptions, type DrHistoryDiff, type DrHistoryEntry, type DrHistoryMark, type DrImageExportOptions, type DrIndicatorPath, type DrInteractionEndPerfEvent, type DrInteractionStartPerfEvent, type DrInterruptEvent, type DrInterruptEventInfo, type DrKeyboardEvent, type DrKeyboardEventInfo, type DrKeyboardEventName, type DrLoadSessionStateSnapshotOptions, type DrLoadSnapshotOptions, type DrMeasureTextOpts, type DrMeasureTextSpanOpts, type DrMeasuredTextSize, type DrOnMountHandler, type DrOverlay, type DrOverlayEntry, type DrOverlayUtilConstructor, type DrPerfEventMap, type DrPerfFrameTimeStats, type DrPerfLongAnimationFrame, type DrPerfLongAnimationFrameScript, type DrPinchEvent, type DrPinchEventInfo, type DrPinchEventName, type DrPointerEvent, type DrPointerEventInfo, type DrPointerEventName, type DrPointerEventTarget, type DrRenderingShape, type DrResizeHandle, type DrResizeInfo, type DrResizeMode, type DrResizeShapeOptions, type DrRotationSnapshot, type DrSelectionBackgroundProps, type DrSelectionHandle, type DrSessionStateSnapshot, type DrShapeErrorFallbackComponent, type DrShapeIndicatorOverlay, type DrShapeOperationPerfEvent, type DrShapeUtilCanBeLaidOutOpts, type DrShapeUtilCanBindOpts, type DrShapeUtilCanvasSvgDef, type DrShapeUtilConstructor, type DrShapeWrapperProps, type DrStateNodeConstructor, type DrStoreBaseOptions, type DrStoreEventInfo, type DrStoreOptions, type DrStoreSchemaOptions, type DrStoreWithStatus, type DrSvgExportOptions, type DrSvgTextExternalContent, type DrTextExternalContent, type DrTextExternalContentSource, type DrTextOptions, type DrTickEvent, type DrTickEventInfo, type DrUndoRedoPerfEvent, type DrUpdatePointerOptions, type DrUrlExternalAsset, type DrUrlExternalContent, type DrUserPreferences, type DrWheelEvent, type DrWheelEventInfo, DrawEditor, type DrawEditorBaseProps, type DrawEditorProps, type DrawEditorStoreProps, type DrawEditorWithStoreProps, type DrawEditorWithoutStoreProps, type DrawOptions, EASINGS, EVENT_NAME_MAP, Edge2d, EdgeScrollManager, Editor, EditorAtom, EditorContext, EditorProvider, type EditorProviderProps, Ellipse2d, ErrorBoundary, ErrorScreen, FontManager, type GapsSnapIndicator, Geometry2d, Geometry2dFilters, type Geometry2dOptions, Group2d, GroupShapeUtil, HALF_PI, HTMLContainer, type HTMLContainerProps, type HandleSnapGeometry, HandleSnaps, HistoryManager, InputsManager, LoadingScreen, type LoadingScreenProps, LocalIndexedDb, Mat, type MatLike, type MatModel, MenuClickCapture, OptionalErrorBoundary, type OptionalKeys, OverlayManager, type OverlayOptionsWithDisplayValues, OverlayUtil, PI, PI2, type PerfectDashTerminal, PerformanceApiAdapter, PerformanceManager, Point2d, type PointsSnapIndicator, Polygon2d, Polyline2d, ROTATE_CORNER_TO_SELECTION_CORNER, ReadonlySharedStyleMap, Rectangle2d, type RequiredKeys, type ResizeBoxOptions, type RichTextFontVisitor, type RichTextFontVisitorState, type RotateCorner, SIDES, SIN, SVGContainer, type SVGContainerProps, type SafeId, type ScribbleItem, ScribbleManager, type ScribbleSessionOptions, type SelectionCorner, type SelectionEdge, type SelectionHandle, ShapeIndicatorOverlayUtil, ShapeUtil, type SharedStyle, SharedStyleMap, type SnapData, type SnapIndicator, SnapManager, SpatialIndexManager, Stadium2d, StateNode, type StoreName, type SvgExportContext, type SvgExportDef, TAB_ID, Table, TextManager, ThemeManager, TickManager, type TiptapEditor, type TiptapNode, TransformedGeometry2d, type TransformedGeometry2dOptions, USER_COLORS, type UiEvent, type UiEventType, UserPreferencesManager, Vec, type VecLike, activeElementShouldCaptureKeys, angleDistance, applyRotationToSnapshotShapes, approximately, areAnglesCompatible, average, canonicalizeRotation, centerOfCircleFromThreePoints, clamp, clampRadians, clampToBrowserMaxCanvasSize, clockwiseAngleDist, coreShapes, counterClockwiseAngleDist, createDebugValue, createDeepLinkString, createDrCurrentUser, createDrSchemaFromUtils, createDrStore, createSessionStateSnapshotSignal, dataUrlToFile, debugFlags, defaultDrawOptions, defaultUserPreferences, defaultUserStore, degreesToRadians, elementShouldCaptureKeys, extractSessionStateFromLegacySnapshot, featureFlags, getArcMeasure, getColorValue, getCursor, getDefaultCdnBaseUrl, getDroppedShapesToNewParents, getFontsFromRichText, getFreshUserPreferences, getGlobalDocument, getGlobalWindow, getIncrementedName, getOverlayDisplayValues, getOwnerDocument, getOwnerWindow, getPerfectDashProps, getPointInArcT, getPointOnCircle, getPointerInfo, getPointsOnArc, getPolygonVertices, getRotationSnapshot, getSnapshot, getSvgAsImage, getSvgPathFromPoints, getUserPreferences, getVerticesCountForArcLength, hardReset, hardResetEditor, inlineBase64AssetStore, intersectCircleCircle, intersectCirclePolygon, intersectCirclePolyline, intersectLineSegmentCircle, intersectLineSegmentLineSegment, intersectLineSegmentPolygon, intersectLineSegmentPolyline, intersectPolygonBounds, intersectPolygonPolygon, isAccelKey, isSafeFloat, kickoutOccludedShapes, linesIntersect, loadSessionStateSnapshotIntoStore, loadSnapshot, loopToHtmlElement, maybeSnapToGrid, normalizeWheel, openWindow, parseDeepLinkString, perimeterOfEllipse, pointInPolygon, polygonIntersectsPolyline, polygonsIntersect, precise, preventDefault, radiansToDegrees, rangeIntersection, refreshPage, releasePointerCapture, resizeBox, resizeScaled, resolveThemes, rotateSelectionHandle, runtime, sanitizeId, setPointerCapture, setRuntimeOverrides, setUserPreferences, shortAngleDist, snapAngle, stopEventPropagation, strokeShapeIndicators, suffixSafeId, tlenv, tlenvReactive, tlmenus, tltime, toDomPrecision, toFixed, toPrecision, uniq, useColorMode, useContainer, useContainerIfExists, useDelaySvgExport, useDrSchemaFromUtils, useDrStore, useDrawCurrentUser, useEditor, useEditorComponents, useEvent, useGlobalMenuIsOpen, useIsCropping, useIsEditing, useLocalStore, useMaybeEditor, useOnMount, usePassThroughMouseOverEvents, usePassThroughWheelEvents, usePeerIds, usePresence, useReactiveEvent, useRefState, useShallowArrayIdentity, useShallowObjectIdentity, useSharedSafeId, useSvgExportContext, useTransform, useUniqueSafeId, useViewportHeight, userTypeValidator };
|
package/dist/index.mjs
CHANGED
|
@@ -6,14 +6,14 @@ import { useQuickReactor, useStateTracking, useValue, useReactor, useAtom, useCo
|
|
|
6
6
|
export * from '@ibodr/state-react';
|
|
7
7
|
import { createComputedCache, Store, squashRecordDiffs, isRecordsDiffEmpty, reverseRecordsDiff, squashRecordDiffsMutable, createEmptyRecordsDiff, AtomMap, AtomSet, IncrementalSetConstructor } from '@ibodr/store';
|
|
8
8
|
export * from '@ibodr/store';
|
|
9
|
-
import { getDefaultTranslationLocale, pageIdValidator, shapeIdValidator, DefaultFontFamilies, UserRecordType, createUserId, registerColorsFromThemes, registerFontsFromThemes, groupShapeProps, groupShapeMigrations, getShapePropKeysByStyle, isShapeId, CameraRecordType, InstancePageStateRecordType, isPageId, PageRecordType, DrDOCUMENT_ID, DrINSTANCE_ID, createBindingId, createShapeId, createCachedUserResolve, isShape, DrPOINTER_ID, pluckPreservingValues, createDrSchema } from '@ibodr/schema';
|
|
9
|
+
import { getDefaultTranslationLocale, pageIdValidator, shapeIdValidator, DR_BOARD_BACKGROUND_TYPES, DefaultFontFamilies, UserRecordType, createUserId, registerColorsFromThemes, registerFontsFromThemes, groupShapeProps, groupShapeMigrations, getShapePropKeysByStyle, isShapeId, CameraRecordType, InstancePageStateRecordType, isPageId, PageRecordType, DrDOCUMENT_ID, DrINSTANCE_ID, createBindingId, createShapeId, createCachedUserResolve, isShape, DrPOINTER_ID, pluckPreservingValues, createDrSchema } from '@ibodr/schema';
|
|
10
10
|
export * from '@ibodr/schema';
|
|
11
11
|
import { T } from '@ibodr/validate';
|
|
12
12
|
export * from '@ibodr/validate';
|
|
13
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
14
|
-
import classNames from 'classnames';
|
|
15
13
|
import * as React from 'react';
|
|
16
14
|
import React__default, { createContext, memo, useRef, useEffect, useLayoutEffect, useCallback, forwardRef, useState, useMemo, useSyncExternalStore, useContext, Fragment as Fragment$1, useDebugValue, useId } from 'react';
|
|
15
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
16
|
+
import classNames from 'classnames';
|
|
17
17
|
import { flushSync } from 'react-dom';
|
|
18
18
|
import { openDB, deleteDB } from 'idb';
|
|
19
19
|
import EventEmitter from 'eventemitter3';
|
|
@@ -32,8 +32,242 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
32
32
|
if (result) __defProp(target, key, result);
|
|
33
33
|
return result;
|
|
34
34
|
};
|
|
35
|
-
function
|
|
36
|
-
return
|
|
35
|
+
function suffixSafeId(id, suffix) {
|
|
36
|
+
return sanitizeId(`${id}_${suffix}`);
|
|
37
|
+
}
|
|
38
|
+
function useUniqueSafeId(suffix) {
|
|
39
|
+
return sanitizeId(`${useId()}${suffix ?? ""}`);
|
|
40
|
+
}
|
|
41
|
+
function useSharedSafeId(id) {
|
|
42
|
+
const idScope = assertExists(useContext(IdContext));
|
|
43
|
+
return sanitizeId(`${idScope}_${id}`);
|
|
44
|
+
}
|
|
45
|
+
function sanitizeId(id) {
|
|
46
|
+
return id.replace(/:/g, "_");
|
|
47
|
+
}
|
|
48
|
+
var IdContext = createContext(null);
|
|
49
|
+
function IdProvider({ children }) {
|
|
50
|
+
const id = useUniqueSafeId();
|
|
51
|
+
return /* @__PURE__ */ jsx(IdContext.Provider, { value: id, children });
|
|
52
|
+
}
|
|
53
|
+
var EditorContext = createContext(null);
|
|
54
|
+
function useEditor() {
|
|
55
|
+
const editor = React__default.useContext(EditorContext);
|
|
56
|
+
if (!editor) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
"useEditor must be used inside of the <Draw /> or <DrawEditor /> components"
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return editor;
|
|
62
|
+
}
|
|
63
|
+
function useMaybeEditor() {
|
|
64
|
+
return React__default.useContext(EditorContext);
|
|
65
|
+
}
|
|
66
|
+
function EditorProvider({ editor, children }) {
|
|
67
|
+
return /* @__PURE__ */ jsx(EditorContext.Provider, { value: editor, children: /* @__PURE__ */ jsx(IdProvider, { children }) });
|
|
68
|
+
}
|
|
69
|
+
function DefaultBackground({ x, y, z }) {
|
|
70
|
+
const editor = useEditor();
|
|
71
|
+
const backgroundType = useValue(
|
|
72
|
+
"backgroundType",
|
|
73
|
+
() => editor.getInstanceState().backgroundType,
|
|
74
|
+
[editor]
|
|
75
|
+
);
|
|
76
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
77
|
+
/* @__PURE__ */ jsx("div", { className: "dr-background" }),
|
|
78
|
+
backgroundType !== "none" && /* @__PURE__ */ jsx(BoardBackgroundPattern, { type: backgroundType, x, y, z })
|
|
79
|
+
] });
|
|
80
|
+
}
|
|
81
|
+
var PATTERN_SPACING = {
|
|
82
|
+
dots: 24,
|
|
83
|
+
grid: 48,
|
|
84
|
+
"hex-grid": 32,
|
|
85
|
+
lined: 32,
|
|
86
|
+
"double-line": 40,
|
|
87
|
+
"double-line-slash": 40,
|
|
88
|
+
checkered: 20
|
|
89
|
+
};
|
|
90
|
+
var ANGLED_LINE_LENGTH = 4e3;
|
|
91
|
+
function wrap(value, size) {
|
|
92
|
+
return (value % size + size) % size;
|
|
93
|
+
}
|
|
94
|
+
function getAngledPatternOffset(x, y, z, angleDeg, s) {
|
|
95
|
+
const rad = angleDeg * Math.PI / 180;
|
|
96
|
+
const nx = -Math.sin(rad);
|
|
97
|
+
const ny = Math.cos(rad);
|
|
98
|
+
const projected = x * z * nx + y * z * ny;
|
|
99
|
+
return wrap(projected, s);
|
|
100
|
+
}
|
|
101
|
+
function AngledLinePattern({ id, angle, spacing, x, y, z, className }) {
|
|
102
|
+
const s = spacing * z;
|
|
103
|
+
const offset = getAngledPatternOffset(x, y, z, angle, s);
|
|
104
|
+
return /* @__PURE__ */ jsx(
|
|
105
|
+
"pattern",
|
|
106
|
+
{
|
|
107
|
+
id,
|
|
108
|
+
width: ANGLED_LINE_LENGTH,
|
|
109
|
+
height: s,
|
|
110
|
+
patternUnits: "userSpaceOnUse",
|
|
111
|
+
patternTransform: `rotate(${angle}) translate(0, ${offset})`,
|
|
112
|
+
children: /* @__PURE__ */ jsx("line", { className, x1: 0, y1: 0, x2: ANGLED_LINE_LENGTH, y2: 0 })
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
function BoardBackgroundPattern({ type, x, y, z }) {
|
|
117
|
+
const id = useUniqueSafeId("board-bg");
|
|
118
|
+
const editor = useEditor();
|
|
119
|
+
const { gridSteps } = editor.options;
|
|
120
|
+
switch (type) {
|
|
121
|
+
case "dots": {
|
|
122
|
+
return /* @__PURE__ */ jsxs("svg", { className: "dr-background-pattern", "aria-hidden": "true", children: [
|
|
123
|
+
/* @__PURE__ */ jsx("defs", { children: gridSteps.map(({ step }) => {
|
|
124
|
+
const s = PATTERN_SPACING.dots * step * z;
|
|
125
|
+
const ox = wrap(0.5 + x * z, s);
|
|
126
|
+
const oy = wrap(0.5 + y * z, s);
|
|
127
|
+
return /* @__PURE__ */ jsx(
|
|
128
|
+
"pattern",
|
|
129
|
+
{
|
|
130
|
+
id: suffixSafeId(id, `${step}`),
|
|
131
|
+
width: s,
|
|
132
|
+
height: s,
|
|
133
|
+
patternUnits: "userSpaceOnUse",
|
|
134
|
+
children: /* @__PURE__ */ jsx("circle", { className: "dr-bg-dot", cx: ox, cy: oy, r: 1.5 })
|
|
135
|
+
},
|
|
136
|
+
step
|
|
137
|
+
);
|
|
138
|
+
}) }),
|
|
139
|
+
gridSteps.map(({ min, mid, step }) => /* @__PURE__ */ jsx(
|
|
140
|
+
"rect",
|
|
141
|
+
{
|
|
142
|
+
width: "100%",
|
|
143
|
+
height: "100%",
|
|
144
|
+
fill: `url(#${suffixSafeId(id, `${step}`)})`,
|
|
145
|
+
opacity: z < mid ? modulate(z, [min, mid], [0, 1], true) : 1
|
|
146
|
+
},
|
|
147
|
+
step
|
|
148
|
+
))
|
|
149
|
+
] });
|
|
150
|
+
}
|
|
151
|
+
case "grid":
|
|
152
|
+
case "checkered": {
|
|
153
|
+
const lineClass = type === "checkered" ? "dr-bg-line-secondary" : "dr-bg-line";
|
|
154
|
+
return /* @__PURE__ */ jsxs("svg", { className: "dr-background-pattern", "aria-hidden": "true", children: [
|
|
155
|
+
/* @__PURE__ */ jsx("defs", { children: gridSteps.map(({ step }) => {
|
|
156
|
+
const s = PATTERN_SPACING[type] * step * z;
|
|
157
|
+
const ox = wrap(0.5 + x * z, s);
|
|
158
|
+
const oy = wrap(0.5 + y * z, s);
|
|
159
|
+
return /* @__PURE__ */ jsx(
|
|
160
|
+
"pattern",
|
|
161
|
+
{
|
|
162
|
+
id: suffixSafeId(id, `${step}`),
|
|
163
|
+
width: s,
|
|
164
|
+
height: s,
|
|
165
|
+
patternUnits: "userSpaceOnUse",
|
|
166
|
+
children: /* @__PURE__ */ jsx(
|
|
167
|
+
"path",
|
|
168
|
+
{
|
|
169
|
+
className: lineClass,
|
|
170
|
+
d: `M ${ox} 0 L ${ox} ${s} M 0 ${oy} L ${s} ${oy}`
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
},
|
|
174
|
+
step
|
|
175
|
+
);
|
|
176
|
+
}) }),
|
|
177
|
+
gridSteps.map(({ min, mid, step }) => /* @__PURE__ */ jsx(
|
|
178
|
+
"rect",
|
|
179
|
+
{
|
|
180
|
+
width: "100%",
|
|
181
|
+
height: "100%",
|
|
182
|
+
fill: `url(#${suffixSafeId(id, `${step}`)})`,
|
|
183
|
+
opacity: z < mid ? modulate(z, [min, mid], [0, 1], true) : 1
|
|
184
|
+
},
|
|
185
|
+
step
|
|
186
|
+
))
|
|
187
|
+
] });
|
|
188
|
+
}
|
|
189
|
+
case "hex-grid": {
|
|
190
|
+
const r = PATTERN_SPACING["hex-grid"] * z;
|
|
191
|
+
const width = 3 * r;
|
|
192
|
+
const height = Math.sqrt(3) * r;
|
|
193
|
+
const ox = wrap(x * z, width);
|
|
194
|
+
const oy = wrap(y * z, height);
|
|
195
|
+
const hexPoints = (cx, cy) => Array.from({ length: 6 }, (_, i) => {
|
|
196
|
+
const angle = Math.PI / 180 * (60 * i);
|
|
197
|
+
return `${cx + r * Math.cos(angle)},${cy + r * Math.sin(angle)}`;
|
|
198
|
+
}).join(" ");
|
|
199
|
+
return /* @__PURE__ */ jsxs("svg", { className: "dr-background-pattern", "aria-hidden": "true", children: [
|
|
200
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs(
|
|
201
|
+
"pattern",
|
|
202
|
+
{
|
|
203
|
+
id,
|
|
204
|
+
width,
|
|
205
|
+
height,
|
|
206
|
+
patternUnits: "userSpaceOnUse",
|
|
207
|
+
patternTransform: `translate(${ox}, ${oy})`,
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ jsx("polygon", { className: "dr-bg-line", points: hexPoints(r, height / 2) }),
|
|
210
|
+
/* @__PURE__ */ jsx("polygon", { className: "dr-bg-line", points: hexPoints(2.5 * r, 0) }),
|
|
211
|
+
/* @__PURE__ */ jsx("polygon", { className: "dr-bg-line", points: hexPoints(2.5 * r, height) }),
|
|
212
|
+
/* @__PURE__ */ jsx("polygon", { className: "dr-bg-line", points: hexPoints(-0.5 * r, 0) }),
|
|
213
|
+
/* @__PURE__ */ jsx("polygon", { className: "dr-bg-line", points: hexPoints(-0.5 * r, height) })
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
) }),
|
|
217
|
+
/* @__PURE__ */ jsx("rect", { width: "100%", height: "100%", fill: `url(#${id})` })
|
|
218
|
+
] });
|
|
219
|
+
}
|
|
220
|
+
case "lined": {
|
|
221
|
+
const s = PATTERN_SPACING.lined * z;
|
|
222
|
+
const oy = wrap(0.5 + y * z, s);
|
|
223
|
+
return /* @__PURE__ */ jsxs("svg", { className: "dr-background-pattern", "aria-hidden": "true", children: [
|
|
224
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("pattern", { id, width: s, height: s, patternUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx("line", { className: "dr-bg-line", x1: 0, y1: oy, x2: s, y2: oy }) }) }),
|
|
225
|
+
/* @__PURE__ */ jsx("rect", { width: "100%", height: "100%", fill: `url(#${id})` })
|
|
226
|
+
] });
|
|
227
|
+
}
|
|
228
|
+
case "double-line":
|
|
229
|
+
case "double-line-slash": {
|
|
230
|
+
const s = PATTERN_SPACING[type] * z;
|
|
231
|
+
const oy = wrap(0.5 + y * z, s);
|
|
232
|
+
const oySecondary = wrap(oy + s / 2, s);
|
|
233
|
+
const diagId = suffixSafeId(id, "diag");
|
|
234
|
+
return /* @__PURE__ */ jsxs("svg", { className: "dr-background-pattern", "aria-hidden": "true", children: [
|
|
235
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
236
|
+
/* @__PURE__ */ jsxs("pattern", { id, width: s, height: s, patternUnits: "userSpaceOnUse", children: [
|
|
237
|
+
/* @__PURE__ */ jsx("line", { className: "dr-bg-line", x1: 0, y1: oy, x2: s, y2: oy }),
|
|
238
|
+
/* @__PURE__ */ jsx(
|
|
239
|
+
"line",
|
|
240
|
+
{
|
|
241
|
+
className: "dr-bg-line-secondary",
|
|
242
|
+
x1: 0,
|
|
243
|
+
y1: oySecondary,
|
|
244
|
+
x2: s,
|
|
245
|
+
y2: oySecondary
|
|
246
|
+
}
|
|
247
|
+
)
|
|
248
|
+
] }),
|
|
249
|
+
type === "double-line-slash" && /* @__PURE__ */ jsx(
|
|
250
|
+
AngledLinePattern,
|
|
251
|
+
{
|
|
252
|
+
id: diagId,
|
|
253
|
+
angle: -65,
|
|
254
|
+
spacing: 22,
|
|
255
|
+
x,
|
|
256
|
+
y,
|
|
257
|
+
z,
|
|
258
|
+
className: "dr-bg-line-secondary"
|
|
259
|
+
}
|
|
260
|
+
)
|
|
261
|
+
] }),
|
|
262
|
+
/* @__PURE__ */ jsx("rect", { width: "100%", height: "100%", fill: `url(#${id})` }),
|
|
263
|
+
type === "double-line-slash" && /* @__PURE__ */ jsx("rect", { width: "100%", height: "100%", fill: `url(#${diagId})` })
|
|
264
|
+
] });
|
|
265
|
+
}
|
|
266
|
+
default: {
|
|
267
|
+
const exhaustiveCheck = type;
|
|
268
|
+
throw new Error(`Unhandled board background type: ${exhaustiveCheck}`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
37
271
|
}
|
|
38
272
|
var featureFlags = {};
|
|
39
273
|
var pointerCaptureTrackingObject = createDebugValue(
|
|
@@ -326,40 +560,6 @@ function getPointerInfo(editor, e) {
|
|
|
326
560
|
isPen: e.pointerType === "pen"
|
|
327
561
|
};
|
|
328
562
|
}
|
|
329
|
-
function suffixSafeId(id, suffix) {
|
|
330
|
-
return sanitizeId(`${id}_${suffix}`);
|
|
331
|
-
}
|
|
332
|
-
function useUniqueSafeId(suffix) {
|
|
333
|
-
return sanitizeId(`${useId()}${suffix ?? ""}`);
|
|
334
|
-
}
|
|
335
|
-
function useSharedSafeId(id) {
|
|
336
|
-
const idScope = assertExists(useContext(IdContext));
|
|
337
|
-
return sanitizeId(`${idScope}_${id}`);
|
|
338
|
-
}
|
|
339
|
-
function sanitizeId(id) {
|
|
340
|
-
return id.replace(/:/g, "_");
|
|
341
|
-
}
|
|
342
|
-
var IdContext = createContext(null);
|
|
343
|
-
function IdProvider({ children }) {
|
|
344
|
-
const id = useUniqueSafeId();
|
|
345
|
-
return /* @__PURE__ */ jsx(IdContext.Provider, { value: id, children });
|
|
346
|
-
}
|
|
347
|
-
var EditorContext = createContext(null);
|
|
348
|
-
function useEditor() {
|
|
349
|
-
const editor = React__default.useContext(EditorContext);
|
|
350
|
-
if (!editor) {
|
|
351
|
-
throw new Error(
|
|
352
|
-
"useEditor must be used inside of the <Draw /> or <DrawEditor /> components"
|
|
353
|
-
);
|
|
354
|
-
}
|
|
355
|
-
return editor;
|
|
356
|
-
}
|
|
357
|
-
function useMaybeEditor() {
|
|
358
|
-
return React__default.useContext(EditorContext);
|
|
359
|
-
}
|
|
360
|
-
function EditorProvider({ editor, children }) {
|
|
361
|
-
return /* @__PURE__ */ jsx(EditorContext.Provider, { value: editor, children: /* @__PURE__ */ jsx(IdProvider, { children }) });
|
|
362
|
-
}
|
|
363
563
|
|
|
364
564
|
// src/lib/hooks/useCanvasEvents.ts
|
|
365
565
|
function useCanvasEvents() {
|
|
@@ -4034,6 +4234,11 @@ function DefaultCanvas({ className }) {
|
|
|
4034
4234
|
);
|
|
4035
4235
|
const hideShapes = useValue("debug_shapes", () => debugFlags.hideShapes.get(), [debugFlags]);
|
|
4036
4236
|
const isGridMode = useValue("isGridMode", () => editor.getInstanceState().isGridMode, [editor]);
|
|
4237
|
+
const backgroundType = useValue(
|
|
4238
|
+
"backgroundType",
|
|
4239
|
+
() => editor.getInstanceState().backgroundType,
|
|
4240
|
+
[editor]
|
|
4241
|
+
);
|
|
4037
4242
|
const { Grid } = useEditorComponents();
|
|
4038
4243
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4039
4244
|
/* @__PURE__ */ jsxs(
|
|
@@ -4049,8 +4254,8 @@ function DefaultCanvas({ className }) {
|
|
|
4049
4254
|
shapeSvgDefs,
|
|
4050
4255
|
SvgDefs && /* @__PURE__ */ jsx(SvgDefs, {})
|
|
4051
4256
|
] }) }),
|
|
4052
|
-
Background && /* @__PURE__ */ jsx("div", { className: "dr-background__wrapper", children: /* @__PURE__ */ jsx(
|
|
4053
|
-
isGridMode && Grid && /* @__PURE__ */ jsx(GridWrapper, {}),
|
|
4257
|
+
Background && /* @__PURE__ */ jsx("div", { className: "dr-background__wrapper", children: /* @__PURE__ */ jsx(BackgroundWrapper, {}) }),
|
|
4258
|
+
isGridMode && backgroundType === "none" && Grid && /* @__PURE__ */ jsx(GridWrapper, {}),
|
|
4054
4259
|
/* @__PURE__ */ jsxs("div", { ref: rHtmlLayer, className: "dr-html-layer dr-shapes", draggable: false, children: [
|
|
4055
4260
|
/* @__PURE__ */ jsx(OnTheCanvasWrapper, {}),
|
|
4056
4261
|
SelectionBackground && /* @__PURE__ */ jsx(SelectionBackgroundWrapper, {}),
|
|
@@ -4089,6 +4294,13 @@ function GridWrapper() {
|
|
|
4089
4294
|
if (!Grid) return null;
|
|
4090
4295
|
return /* @__PURE__ */ jsx(Grid, { x, y, z, size: gridSize });
|
|
4091
4296
|
}
|
|
4297
|
+
function BackgroundWrapper() {
|
|
4298
|
+
const editor = useEditor();
|
|
4299
|
+
const { x, y, z } = useValue("camera", () => editor.getCamera(), [editor]);
|
|
4300
|
+
const { Background } = useEditorComponents();
|
|
4301
|
+
if (!Background) return null;
|
|
4302
|
+
return /* @__PURE__ */ jsx(Background, { x, y, z });
|
|
4303
|
+
}
|
|
4092
4304
|
function ShapesLayer({ canvasRef }) {
|
|
4093
4305
|
const editor = useEditor();
|
|
4094
4306
|
const debugSvg = useValue("debug svg", () => debugFlags.debugSvg.get(), [debugFlags]);
|
|
@@ -5906,6 +6118,7 @@ var sessionStateSnapshotValidator = T.object({
|
|
|
5906
6118
|
isDebugMode: T.boolean.optional(),
|
|
5907
6119
|
isToolLocked: T.boolean.optional(),
|
|
5908
6120
|
isGridMode: T.boolean.optional(),
|
|
6121
|
+
backgroundType: T.literalEnum(...DR_BOARD_BACKGROUND_TYPES).optional(),
|
|
5909
6122
|
pageStates: T.arrayOf(
|
|
5910
6123
|
T.object({
|
|
5911
6124
|
pageId: pageIdValidator,
|
|
@@ -5955,6 +6168,7 @@ function createSessionStateSnapshotSignal(store) {
|
|
|
5955
6168
|
isDebugMode: instanceState.isDebugMode,
|
|
5956
6169
|
isToolLocked: instanceState.isToolLocked,
|
|
5957
6170
|
isGridMode: instanceState.isGridMode,
|
|
6171
|
+
backgroundType: instanceState.backgroundType,
|
|
5958
6172
|
pageStates: allPageIds.map((id) => {
|
|
5959
6173
|
const ps = store.get(InstancePageStateRecordType.createId(id));
|
|
5960
6174
|
const camera = store.get(CameraRecordType.createId(id));
|
|
@@ -5990,6 +6204,7 @@ function loadSessionStateSnapshotIntoStore(store, snapshot, opts) {
|
|
|
5990
6204
|
isFocusMode: primary?.isFocusMode ?? secondary?.isFocusMode,
|
|
5991
6205
|
isToolLocked: primary?.isToolLocked ?? secondary?.isToolLocked,
|
|
5992
6206
|
isGridMode: primary?.isGridMode ?? secondary?.isGridMode,
|
|
6207
|
+
backgroundType: primary?.backgroundType ?? secondary?.backgroundType,
|
|
5993
6208
|
exportBackground: primary?.exportBackground ?? secondary?.exportBackground
|
|
5994
6209
|
});
|
|
5995
6210
|
store.atomic(() => {
|
|
@@ -6037,6 +6252,7 @@ function extractSessionStateFromLegacySnapshot(store) {
|
|
|
6037
6252
|
isDebugMode: !!oldInstance.isDebugMode,
|
|
6038
6253
|
isToolLocked: !!oldInstance.isToolLocked,
|
|
6039
6254
|
isGridMode: false,
|
|
6255
|
+
backgroundType: oldInstance.backgroundType ?? "none",
|
|
6040
6256
|
pageStates: instanceRecords.filter((r) => r.typeName === "instance_page_state" && r.instanceId === oldInstance.id).map((ps) => {
|
|
6041
6257
|
const camera = store[ps.cameraId] ?? { x: 0, y: 0, z: 1 };
|
|
6042
6258
|
return {
|
|
@@ -24842,7 +25058,7 @@ function getFontsFromRichText(editor, richText, initialState2) {
|
|
|
24842
25058
|
// src/index.ts
|
|
24843
25059
|
registerDrawLibraryVersion(
|
|
24844
25060
|
"@ibodr/editor",
|
|
24845
|
-
"0.1.
|
|
25061
|
+
"0.1.11",
|
|
24846
25062
|
"esm"
|
|
24847
25063
|
);
|
|
24848
25064
|
/*!
|