@ibodr/editor 0.1.10 → 0.1.12

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 CHANGED
@@ -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 {
@@ -43,7 +49,7 @@ interface DrUserPreferences {
43
49
  animationSpeed?: number | null;
44
50
  areKeyboardShortcutsEnabled?: boolean | null;
45
51
  edgeScrollSpeed?: number | null;
46
- colorScheme?: 'light' | 'dark' | 'system';
52
+ colorScheme?: 'light' | 'dark' | 'system' | 'inherit';
47
53
  isSnapMode?: boolean | null;
48
54
  isWrapMode?: boolean | null;
49
55
  isDynamicSizeMode?: boolean | null;
@@ -4154,7 +4160,7 @@ declare class UserPreferencesManager {
4154
4160
  systemColorScheme: _ibodr_state.Atom<"light" | "dark", unknown>;
4155
4161
  disposables: Set<() => void>;
4156
4162
  dispose(): void;
4157
- constructor(user: DrCurrentUser, colorScheme: 'light' | 'dark' | 'system');
4163
+ constructor(user: DrCurrentUser, colorScheme: 'light' | 'dark' | 'system' | 'inherit');
4158
4164
  updateUserPreferences(userPreferences: Partial<DrUserPreferences>): void;
4159
4165
  getUserPreferences(): {
4160
4166
  id: string;
@@ -4164,7 +4170,7 @@ declare class UserPreferencesManager {
4164
4170
  animationSpeed: number;
4165
4171
  areKeyboardShortcutsEnabled: boolean;
4166
4172
  isSnapMode: boolean;
4167
- colorScheme: "light" | "dark" | "system" | undefined;
4173
+ colorScheme: "light" | "dark" | "system" | "inherit" | undefined;
4168
4174
  isDarkMode: boolean;
4169
4175
  isWrapMode: boolean;
4170
4176
  isDynamicResizeMode: boolean;
@@ -4529,7 +4535,7 @@ interface DrEditorOptions {
4529
4535
  * - `'dark'` - Always use dark mode.
4530
4536
  * - `'system'` - Follow the OS color scheme preference.
4531
4537
  */
4532
- colorScheme?: 'light' | 'dark' | 'system';
4538
+ colorScheme?: 'light' | 'dark' | 'system' | 'inherit';
4533
4539
  /**
4534
4540
  * Additional configuration options for the tldraw editor.
4535
4541
  */
@@ -9094,7 +9100,7 @@ interface DrCollaboratorCursorProps {
9094
9100
 
9095
9101
  /** @public */
9096
9102
  interface DrEditorComponents {
9097
- Background?: ComponentType | null;
9103
+ Background?: ComponentType<DrBackgroundProps> | null;
9098
9104
  Canvas?: ComponentType<DrCanvasComponentProps> | null;
9099
9105
  Grid?: ComponentType<DrGridProps> | null;
9100
9106
  /** Renders a single collaborator cursor. Pass `null` to hide cursors entirely. */
@@ -9997,8 +10003,10 @@ interface DrawEditorBaseProps {
9997
10003
  * - `'light'` - Always use light mode.
9998
10004
  * - `'dark'` - Always use dark mode.
9999
10005
  * - `'system'` - Follow the OS color scheme preference.
10006
+ * - `'inherit'` - Follow the nearest ancestor's `data-color-mode` attribute
10007
+ * (for embedding inside a host app that manages its own theme).
10000
10008
  */
10001
- colorScheme?: 'light' | 'dark' | 'system';
10009
+ colorScheme?: 'light' | 'dark' | 'system' | 'inherit';
10002
10010
  /**
10003
10011
  * Named themes for the editor.
10004
10012
  */
@@ -10427,4 +10435,4 @@ declare function uniq<T>(array: {
10427
10435
  readonly [n: number]: T;
10428
10436
  } | null | undefined): T[];
10429
10437
 
10430
- 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 };
10438
+ 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
@@ -10,10 +10,10 @@ import { getDefaultTranslationLocale, pageIdValidator, shapeIdValidator, DR_BOAR
10
10
  export * from '@ibodr/schema';
11
11
  import { T } from '@ibodr/validate';
12
12
  export * from '@ibodr/validate';
13
- import classNames2 from 'classnames';
14
13
  import * as React from 'react';
15
14
  import React__default, { createContext, memo, useRef, useEffect, useLayoutEffect, useCallback, forwardRef, useState, useMemo, useSyncExternalStore, useContext, Fragment as Fragment$1, useDebugValue, useId } from 'react';
16
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';
@@ -66,23 +66,209 @@ function useMaybeEditor() {
66
66
  function EditorProvider({ editor, children }) {
67
67
  return /* @__PURE__ */ jsx(EditorContext.Provider, { value: editor, children: /* @__PURE__ */ jsx(IdProvider, { children }) });
68
68
  }
69
- function DefaultBackground() {
69
+ function DefaultBackground({ x, y, z }) {
70
70
  const editor = useEditor();
71
71
  const backgroundType = useValue(
72
72
  "backgroundType",
73
73
  () => editor.getInstanceState().backgroundType,
74
74
  [editor]
75
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);
76
104
  return /* @__PURE__ */ jsx(
77
- "div",
105
+ "pattern",
78
106
  {
79
- className: classNames2(
80
- "dr-background",
81
- backgroundType !== "none" && `dr-background__${backgroundType}`
82
- )
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 })
83
113
  }
84
114
  );
85
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
+ }
271
+ }
86
272
  var featureFlags = {};
87
273
  var pointerCaptureTrackingObject = createDebugValue(
88
274
  "pointerCaptureTrackingObject",
@@ -4048,6 +4234,11 @@ function DefaultCanvas({ className }) {
4048
4234
  );
4049
4235
  const hideShapes = useValue("debug_shapes", () => debugFlags.hideShapes.get(), [debugFlags]);
4050
4236
  const isGridMode = useValue("isGridMode", () => editor.getInstanceState().isGridMode, [editor]);
4237
+ const backgroundType = useValue(
4238
+ "backgroundType",
4239
+ () => editor.getInstanceState().backgroundType,
4240
+ [editor]
4241
+ );
4051
4242
  const { Grid } = useEditorComponents();
4052
4243
  return /* @__PURE__ */ jsxs(Fragment, { children: [
4053
4244
  /* @__PURE__ */ jsxs(
@@ -4055,7 +4246,7 @@ function DefaultCanvas({ className }) {
4055
4246
  {
4056
4247
  ref: rCanvas,
4057
4248
  draggable: false,
4058
- className: classNames2("dr-canvas", className),
4249
+ className: classNames("dr-canvas", className),
4059
4250
  "data-testid": "canvas",
4060
4251
  ...events,
4061
4252
  children: [
@@ -4063,8 +4254,8 @@ function DefaultCanvas({ className }) {
4063
4254
  shapeSvgDefs,
4064
4255
  SvgDefs && /* @__PURE__ */ jsx(SvgDefs, {})
4065
4256
  ] }) }),
4066
- Background && /* @__PURE__ */ jsx("div", { className: "dr-background__wrapper", children: /* @__PURE__ */ jsx(Background, {}) }),
4067
- 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, {}),
4068
4259
  /* @__PURE__ */ jsxs("div", { ref: rHtmlLayer, className: "dr-html-layer dr-shapes", draggable: false, children: [
4069
4260
  /* @__PURE__ */ jsx(OnTheCanvasWrapper, {}),
4070
4261
  SelectionBackground && /* @__PURE__ */ jsx(SelectionBackgroundWrapper, {}),
@@ -4103,6 +4294,13 @@ function GridWrapper() {
4103
4294
  if (!Grid) return null;
4104
4295
  return /* @__PURE__ */ jsx(Grid, { x, y, z, size: gridSize });
4105
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
+ }
4106
4304
  function ShapesLayer({ canvasRef }) {
4107
4305
  const editor = useEditor();
4108
4306
  const debugSvg = useValue("debug svg", () => debugFlags.debugSvg.get(), [debugFlags]);
@@ -4245,7 +4443,7 @@ function MovingCameraHitTestBlocker() {
4245
4443
  return /* @__PURE__ */ jsx(
4246
4444
  "div",
4247
4445
  {
4248
- className: classNames2("dr-hit-test-blocker", {
4446
+ className: classNames("dr-hit-test-blocker", {
4249
4447
  "dr-hit-test-blocker__hidden": cameraState === "idle"
4250
4448
  })
4251
4449
  }
@@ -4626,7 +4824,7 @@ My browser: ${navigator.userAgent}`
4626
4824
  "div",
4627
4825
  {
4628
4826
  ref: containerRef,
4629
- className: classNames2(
4827
+ className: classNames(
4630
4828
  "dr-container tl-error-boundary",
4631
4829
  // error-boundary is sometimes used outside of the theme
4632
4830
  // container, so we need to provide it with a theme for our
@@ -4645,7 +4843,7 @@ My browser: ${navigator.userAgent}`
4645
4843
  /* @__PURE__ */ jsx(
4646
4844
  "div",
4647
4845
  {
4648
- className: classNames2("dr-modal", "dr-error-boundary__content", {
4846
+ className: classNames("dr-modal", "dr-error-boundary__content", {
4649
4847
  "dr-error-boundary__content__expanded": shouldShowError && !shouldShowResetConfirmation
4650
4848
  }),
4651
4849
  children: shouldShowResetConfirmation ? /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -4766,7 +4964,7 @@ var DefaultShapeWrapper = forwardRef(function DefaultShapeWrapper2({ children, s
4766
4964
  "data-shape-id": shape.id,
4767
4965
  draggable: false,
4768
4966
  ...props,
4769
- className: classNames2("dr-shape", isBackground && "dr-shape-background", props.className),
4967
+ className: classNames("dr-shape", isBackground && "dr-shape-background", props.className),
4770
4968
  children
4771
4969
  }
4772
4970
  );
@@ -4780,7 +4978,7 @@ function DefaultSpinner(props) {
4780
4978
  viewBox: "0 0 16 16",
4781
4979
  "aria-hidden": "false",
4782
4980
  ...props,
4783
- className: classNames2("dr-spinner", props.className),
4981
+ className: classNames("dr-spinner", props.className),
4784
4982
  children: /* @__PURE__ */ jsxs("g", { strokeWidth: 2, fill: "none", fillRule: "evenodd", children: [
4785
4983
  /* @__PURE__ */ jsx("circle", { strokeOpacity: 0.25, cx: 8, cy: 8, r: 7, stroke: "currentColor" }),
4786
4984
  /* @__PURE__ */ jsx("path", { strokeLinecap: "round", d: "M15 8c0-4.5-4.5-7-7-7", stroke: "currentColor" })
@@ -4794,10 +4992,10 @@ var DefaultSvgDefs = () => {
4794
4992
  return null;
4795
4993
  };
4796
4994
  function HTMLContainer({ children, className = "", ...rest }) {
4797
- return /* @__PURE__ */ jsx("div", { ...rest, className: classNames2("dr-html-container", className), children });
4995
+ return /* @__PURE__ */ jsx("div", { ...rest, className: classNames("dr-html-container", className), children });
4798
4996
  }
4799
4997
  function SVGContainer({ children, className = "", ...rest }) {
4800
- return /* @__PURE__ */ jsx("svg", { ...rest, className: classNames2("dr-svg-container", className), "aria-hidden": "true", children });
4998
+ return /* @__PURE__ */ jsx("svg", { ...rest, className: classNames("dr-svg-container", className), "aria-hidden": "true", children });
4801
4999
  }
4802
5000
  function useIdentity(value, isEqual2) {
4803
5001
  const ref = useRef(value);
@@ -4845,7 +5043,7 @@ var userTypeValidator = T.object({
4845
5043
  animationSpeed: T.number.nullable().optional(),
4846
5044
  areKeyboardShortcutsEnabled: T.boolean.nullable().optional(),
4847
5045
  edgeScrollSpeed: T.number.nullable().optional(),
4848
- colorScheme: T.literalEnum("light", "dark", "system").optional(),
5046
+ colorScheme: T.literalEnum("light", "dark", "system", "inherit").optional(),
4849
5047
  isSnapMode: T.boolean.nullable().optional(),
4850
5048
  isWrapMode: T.boolean.nullable().optional(),
4851
5049
  isDynamicSizeMode: T.boolean.nullable().optional(),
@@ -24345,6 +24543,25 @@ var Stadium2d = class extends Geometry2d {
24345
24543
  return [a, b, c, d].map((p, i) => p.getSvgPathData(i === 0)).join(" ") + " Z";
24346
24544
  }
24347
24545
  };
24546
+
24547
+ // src/lib/utils/resolveInheritedColorMode.ts
24548
+ function resolveInheritedColorMode(container) {
24549
+ const doc = container.ownerDocument;
24550
+ const candidates = [];
24551
+ let el = container.parentElement;
24552
+ while (el) {
24553
+ candidates.push(el);
24554
+ el = el.parentElement;
24555
+ }
24556
+ if (doc?.documentElement) {
24557
+ candidates.push(doc.documentElement);
24558
+ }
24559
+ for (const node of candidates) {
24560
+ const mode = node.getAttribute("data-color-mode");
24561
+ if (mode === "dark" || mode === "light") return mode;
24562
+ }
24563
+ return null;
24564
+ }
24348
24565
  function useDarkMode() {
24349
24566
  const editor = useEditor();
24350
24567
  const container = useContainer();
@@ -24448,7 +24665,7 @@ var DrawEditor = memo(function DrawEditor2({
24448
24665
  ref: setContainer,
24449
24666
  "data-tldraw": version,
24450
24667
  draggable: false,
24451
- className: classNames2(`${TL_CONTAINER_CLASS} tl-theme__light`, className),
24668
+ className: classNames(`${TL_CONTAINER_CLASS} tl-theme__light`, className),
24452
24669
  tabIndex: -1,
24453
24670
  role: "application",
24454
24671
  "aria-label": _options?.branding ?? "tldraw",
@@ -24660,6 +24877,36 @@ function DrawEditorWithReadyStore({
24660
24877
  editor.setCurrentTheme(initialTheme);
24661
24878
  }
24662
24879
  }, [editor, initialTheme]);
24880
+ useLayoutEffect(() => {
24881
+ if (!editor || !colorScheme || colorScheme === "system" || colorScheme === "inherit") return;
24882
+ editor.setColorMode(colorScheme);
24883
+ }, [editor, colorScheme]);
24884
+ useLayoutEffect(() => {
24885
+ if (!editor || colorScheme !== "inherit") return;
24886
+ const container2 = editor.getContainer();
24887
+ const sync = () => {
24888
+ const inherited = resolveInheritedColorMode(container2);
24889
+ if (inherited) {
24890
+ editor.setColorMode(inherited);
24891
+ }
24892
+ };
24893
+ sync();
24894
+ const observer = new MutationObserver(sync);
24895
+ const targets = /* @__PURE__ */ new Set();
24896
+ let el = container2.parentElement;
24897
+ while (el) {
24898
+ targets.add(el);
24899
+ el = el.parentElement;
24900
+ }
24901
+ targets.add(container2.ownerDocument.documentElement);
24902
+ for (const target of targets) {
24903
+ observer.observe(target, {
24904
+ attributes: true,
24905
+ attributeFilter: ["data-color-mode", "class"]
24906
+ });
24907
+ }
24908
+ return () => observer.disconnect();
24909
+ }, [editor, colorScheme]);
24663
24910
  const crashingError = useSyncExternalStore(
24664
24911
  useCallback(
24665
24912
  (onStoreChange) => {
@@ -24860,7 +25107,7 @@ function getFontsFromRichText(editor, richText, initialState2) {
24860
25107
  // src/index.ts
24861
25108
  registerDrawLibraryVersion(
24862
25109
  "@ibodr/editor",
24863
- "0.1.10",
25110
+ "0.1.12",
24864
25111
  "esm"
24865
25112
  );
24866
25113
  /*!