@tldraw/editor 5.3.0-canary.da7dc7ee3db8 → 5.3.0-canary.dee64fee16b5
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-cjs/index.d.ts +171 -7
- package/dist-cjs/index.js +13 -3
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +30 -20
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/EditorPortal.js +44 -0
- package/dist-cjs/lib/components/EditorPortal.js.map +7 -0
- package/dist-cjs/lib/components/LiveCollaborators.js +102 -0
- package/dist-cjs/lib/components/LiveCollaborators.js.map +7 -0
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +4 -10
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +3 -3
- package/dist-cjs/lib/components/default-components/DefaultCursor.js +59 -0
- package/dist-cjs/lib/components/default-components/DefaultCursor.js.map +7 -0
- package/dist-cjs/lib/editor/Editor.js +46 -22
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js +4 -4
- package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FontManager/FontManager.js +9 -0
- package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +8 -1
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
- package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
- package/dist-cjs/lib/hooks/EditorComponentsContext.js.map +2 -2
- package/dist-cjs/lib/hooks/useCursor.js +1 -0
- package/dist-cjs/lib/hooks/useCursor.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js +2 -0
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js +25 -1
- package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useTransform.js +45 -0
- package/dist-cjs/lib/hooks/useTransform.js.map +7 -0
- package/dist-cjs/lib/hooks/useViewportHeight.js.map +2 -2
- package/dist-cjs/lib/license/LicenseManager.js +65 -7
- package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
- package/dist-cjs/lib/license/useLicenseManagerState.js +7 -0
- package/dist-cjs/lib/license/useLicenseManagerState.js.map +2 -2
- package/dist-cjs/lib/options.js +2 -1
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/utils/collaborators.js +27 -0
- package/dist-cjs/lib/utils/collaborators.js.map +7 -0
- package/dist-cjs/lib/utils/getHtmlLayerTransform.js +33 -0
- package/dist-cjs/lib/utils/getHtmlLayerTransform.js.map +7 -0
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +171 -7
- package/dist-esm/index.mjs +19 -4
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +29 -19
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/EditorPortal.mjs +24 -0
- package/dist-esm/lib/components/EditorPortal.mjs.map +7 -0
- package/dist-esm/lib/components/LiveCollaborators.mjs +82 -0
- package/dist-esm/lib/components/LiveCollaborators.mjs.map +7 -0
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +5 -11
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCursor.mjs +29 -0
- package/dist-esm/lib/components/default-components/DefaultCursor.mjs.map +7 -0
- package/dist-esm/lib/editor/Editor.mjs +46 -22
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs +5 -5
- package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs +9 -0
- package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +8 -1
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/hooks/EditorComponentsContext.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCursor.mjs +1 -0
- package/dist-esm/lib/hooks/useCursor.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs +2 -0
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs +25 -1
- package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useTransform.mjs +25 -0
- package/dist-esm/lib/hooks/useTransform.mjs.map +7 -0
- package/dist-esm/lib/hooks/useViewportHeight.mjs.map +2 -2
- package/dist-esm/lib/license/LicenseManager.mjs +66 -8
- package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
- package/dist-esm/lib/license/useLicenseManagerState.mjs +7 -0
- package/dist-esm/lib/license/useLicenseManagerState.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +2 -1
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/utils/collaborators.mjs +7 -0
- package/dist-esm/lib/utils/collaborators.mjs.map +7 -0
- package/dist-esm/lib/utils/getHtmlLayerTransform.mjs +13 -0
- package/dist-esm/lib/utils/getHtmlLayerTransform.mjs.map +7 -0
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +53 -4
- package/package.json +7 -7
- package/src/index.ts +15 -2
- package/src/lib/TldrawEditor.tsx +31 -14
- package/src/lib/components/EditorPortal.tsx +77 -0
- package/src/lib/components/LiveCollaborators.tsx +133 -0
- package/src/lib/components/default-components/DefaultCanvas.tsx +5 -17
- package/src/lib/components/default-components/DefaultCursor.tsx +65 -0
- package/src/lib/editor/Editor.ts +74 -20
- package/src/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.test.ts +46 -1
- package/src/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.ts +10 -5
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +66 -0
- package/src/lib/editor/managers/FontManager/FontManager.ts +14 -0
- package/src/lib/editor/managers/TextManager/TextManager.test.ts +42 -0
- package/src/lib/editor/managers/TextManager/TextManager.ts +11 -2
- package/src/lib/editor/shapes/ShapeUtil.ts +24 -0
- package/src/lib/editor/types/emit-types.ts +1 -0
- package/src/lib/editor/types/external-content.ts +5 -0
- package/src/lib/hooks/EditorComponentsContext.tsx +2 -0
- package/src/lib/hooks/useCursor.ts +1 -0
- package/src/lib/hooks/useEditorComponents.tsx +2 -0
- package/src/lib/hooks/usePassThroughWheelEvents.ts +44 -2
- package/src/lib/hooks/useTransform.ts +38 -0
- package/src/lib/hooks/useViewportHeight.ts +9 -1
- package/src/lib/license/LicenseManager.test.ts +245 -29
- package/src/lib/license/LicenseManager.ts +114 -6
- package/src/lib/license/useLicenseManagerState.ts +17 -1
- package/src/lib/options.ts +3 -1
- package/src/lib/test/EditorPortal.test.tsx +48 -0
- package/src/lib/utils/collaborators.test.ts +34 -0
- package/src/lib/utils/collaborators.ts +25 -0
- package/src/lib/utils/getHtmlLayerTransform.ts +22 -0
- package/src/version.ts +3 -3
- package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js +0 -51
- package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js.map +0 -7
- package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs +0 -31
- package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs.map +0 -7
- package/src/lib/hooks/usePassThroughMouseOverEvents.ts +0 -32
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/options.ts"],
|
|
4
|
-
"sourcesContent": ["import { Awaitable } from '@tldraw/utils'\nimport { ComponentType, Fragment } from 'react'\nimport { DEFAULT_CAMERA_OPTIONS } from './constants'\nimport type { Editor } from './editor/Editor'\nimport { TLContent } from './editor/types/clipboard-types'\nimport { TLExternalContent } from './editor/types/external-content'\nimport { TLCameraOptions } from './editor/types/misc-types'\nimport { VecLike } from './primitives/Vec'\nimport { TLDeepLinkOptions } from './utils/deepLinks'\nimport { TLTextOptions } from './utils/richText'\n\n/**\n * Identifies how a clipboard write was triggered (copy vs cut, keyboard vs menu).\n *\n * @public\n */\nexport interface TLClipboardWriteInfo {\n\treadonly operation: 'copy' | 'cut'\n\treadonly source: 'native' | 'menu'\n}\n\n/**\n * Raw clipboard paste payload, before tldraw parses clipboard contents into {@link TLExternalContent}.\n *\n * - `native-event`: from the `paste` event \u2014 `clipboardData` is available synchronously (unlike async\n * `navigator.clipboard.read()`).\n * - `clipboard-read`: from an explicit `navigator.clipboard.read()` call \u2014 only `ClipboardItem[]`\n * exists\n * (no `DataTransfer`).\n *\n * @public\n */\nexport type TLClipboardPasteRawInfo =\n\t| {\n\t\t\treadonly editor: Editor\n\t\t\treadonly source: 'native-event'\n\t\t\treadonly event: ClipboardEvent\n\t\t\treadonly clipboardData: DataTransfer | null\n\t\t\treadonly point: VecLike | undefined\n\t }\n\t| {\n\t\t\treadonly editor: Editor\n\t\t\treadonly source: 'clipboard-read'\n\t\t\treadonly clipboardItems: readonly ClipboardItem[]\n\t\t\treadonly point: VecLike | undefined\n\t }\n\n/**\n * Options for configuring tldraw. For defaults, see {@link defaultTldrawOptions}.\n *\n * @example\n * ```tsx\n * const options: Partial<TldrawOptions> = {\n * maxPages: 3,\n * maxShapesPerPage: 1000,\n * }\n *\n * function MyTldrawComponent() {\n * return <Tldraw options={options} />\n * }\n * ```\n *\n * @public\n */\nexport interface TldrawOptions {\n\treadonly maxShapesPerPage: number\n\treadonly maxFilesAtOnce: number\n\treadonly maxPages: number\n\treadonly animationMediumMs: number\n\treadonly followChaseViewportSnap: number\n\treadonly doubleClickDurationMs: number\n\treadonly multiClickDurationMs: number\n\treadonly coarseDragDistanceSquared: number\n\treadonly dragDistanceSquared: number\n\treadonly uiDragDistanceSquared: number\n\treadonly uiCoarseDragDistanceSquared: number\n\treadonly defaultSvgPadding: number\n\treadonly cameraSlideFriction: number\n\treadonly gridSteps: readonly {\n\t\treadonly min: number\n\t\treadonly mid: number\n\t\treadonly step: number\n\t}[]\n\treadonly collaboratorInactiveTimeoutMs: number\n\treadonly collaboratorIdleTimeoutMs: number\n\treadonly collaboratorCheckIntervalMs: number\n\treadonly cameraMovingTimeoutMs: number\n\treadonly hitTestMargin: number\n\treadonly edgeScrollDelay: number\n\treadonly edgeScrollEaseDuration: number\n\treadonly edgeScrollSpeed: number\n\treadonly edgeScrollDistance: number\n\treadonly coarsePointerWidth: number\n\treadonly coarseHandleRadius: number\n\treadonly handleRadius: number\n\treadonly longPressDurationMs: number\n\treadonly textShadowLod: number\n\treadonly adjacentShapeMargin: number\n\treadonly flattenImageBoundsExpand: number\n\treadonly flattenImageBoundsPadding: number\n\treadonly laserDelayMs: number\n\t/**\n\t * How long (in milliseconds) to fade all laser scribbles after the session ends.\n\t * The total points across all scribbles will be removed proportionally over this duration.\n\t * Defaults to 500ms (0.5 seconds).\n\t */\n\treadonly laserFadeoutMs: number\n\treadonly maxExportDelayMs: number\n\treadonly tooltipDelayMs: number\n\t/**\n\t * How long should previews created by {@link Editor.createTemporaryAssetPreview} last before\n\t * they expire? Defaults to 3 minutes.\n\t */\n\treadonly temporaryAssetPreviewLifetimeMs: number\n\treadonly actionShortcutsLocation: 'menu' | 'toolbar' | 'swap'\n\treadonly createTextOnCanvasDoubleClick: boolean\n\t/**\n\t * The react provider to use when exporting an image. This is useful if your shapes depend on\n\t * external context providers. By default, this is `React.Fragment`.\n\t */\n\treadonly exportProvider: ComponentType<{ children: React.ReactNode }>\n\t/**\n\t * By default, the toolbar items are accessible via number shortcuts according to their order. To disable this, set this option to false.\n\t */\n\treadonly enableToolbarKeyboardShortcuts: boolean\n\t/**\n\t * The maximum number of fonts that will be loaded while blocking the main rendering of the\n\t * canvas. If there are more than this number of fonts needed, we'll just show the canvas right\n\t * away and let the fonts load in in the background.\n\t */\n\treadonly maxFontsToLoadBeforeRender: number\n\t/**\n\t * If you have a CSP policy that blocks inline styles, you can use this prop to provide a\n\t * nonce to use in the editor's styles.\n\t */\n\treadonly nonce: string | undefined\n\t/**\n\t * Branding name of the app, currently only used for adding aria-label for the application.\n\t */\n\treadonly branding?: string\n\t/**\n\t * Whether to use debounced zoom level for certain rendering optimizations. When true,\n\t * `editor.getEfficientZoomLevel()` returns a cached zoom value while the camera is moving,\n\t * reducing re-renders. When false, it always returns the current zoom level.\n\t */\n\treadonly debouncedZoom: boolean\n\t/**\n\t * The number of shapes that must be on the page for the debounced zoom level to be used.\n\t * Defaults to 500 shapes.\n\t */\n\treadonly debouncedZoomThreshold: number\n\t/**\n\t * Whether to allow spacebar panning. When true, the spacebar will pan the camera when held down.\n\t * When false, the spacebar will not pan the camera.\n\t */\n\treadonly spacebarPanning: boolean\n\t/**\n\t * Whether to allow right-click + drag to pan the camera. When true, right-click + drag pans the\n\t * camera and a static right-click opens the context menu at the release position. When false,\n\t * right-click opens the context menu on press (no drag-to-pan).\n\t */\n\treadonly rightClickPanning: boolean\n\t/**\n\t * The default padding (in pixels) used when zooming to fit content in the viewport.\n\t * This affects methods like `zoomToFit()`, `zoomToSelection()`, and `zoomToBounds()`.\n\t * The actual padding used is the minimum of this value and 28% of the viewport width.\n\t * Defaults to 128 pixels.\n\t */\n\treadonly zoomToFitPadding: number\n\t/**\n\t * The distance (in screen pixels) at which shapes snap to guides and other shapes.\n\t */\n\treadonly snapThreshold: number\n\t/**\n\t * Whether locked shapes can be selected with a left click. When false (default), left-clicking\n\t * a locked shape is treated as a click on the canvas \u2014 only right-click selects it. When true,\n\t * locked shapes can be selected via left click and included in brush and scribble selections,\n\t * but the editor's lock guards still prevent moving, resizing, editing, or deleting them.\n\t */\n\treadonly selectLockedShapes: boolean\n\t/**\n\t * Options for the editor's camera. These are the initial camera options.\n\t * Use {@link Editor.setCameraOptions} to update camera options at runtime.\n\t */\n\treadonly camera: Partial<TLCameraOptions>\n\t/**\n\t * Options for the editor's text rendering. These include TipTap configuration and\n\t * font handling. These are the initial text options and cannot be changed at runtime.\n\t */\n\treadonly text: TLTextOptions\n\t/**\n\t * Options for syncing the editor's camera state with the URL. Set to `true` to enable\n\t * with default options, or pass an options object to customize behavior.\n\t *\n\t * @example\n\t * ```tsx\n\t * // Enable with defaults\n\t * <Tldraw options={{ deepLinks: true }} />\n\t *\n\t * // Enable with custom options\n\t * <Tldraw options={{ deepLinks: { param: 'd', debounceMs: 500 } }} />\n\t * ```\n\t */\n\treadonly deepLinks: true | TLDeepLinkOptions | undefined\n\t/**\n\t * Whether the quick-zoom brush preserves its screen-pixel size when the user\n\t * zooms the overview. When true, zooming in shrinks the target viewport (higher\n\t * return zoom); zooming out expands it. When false, the brush keeps the original\n\t * viewport's page dimensions regardless of overview zoom changes.\n\t */\n\treadonly quickZoomPreservesScreenBounds: boolean\n\t/**\n\t * Called before content is written to the clipboard during a copy or cut operation.\n\t * Receives the serialized content (shapes, bindings, assets) and can filter or transform\n\t * it before it reaches the clipboard.\n\t *\n\t * Return a modified `TLContent` object to change what is copied or cut. Return `false` to\n\t * cancel the clipboard write (for cut, the selected shapes are not removed). Return `void`\n\t * (or `undefined`) to pass through unchanged. You may return a `Promise` of those values if\n\t * the hook is async.\n\t *\n\t * @example\n\t * ```tsx\n\t * // Filter out \"locked\" shapes from copy\n\t * onBeforeCopyToClipboard({ content, operation }) {\n\t * return {\n\t * ...content,\n\t * shapes: content.shapes.filter(s => !s.meta.locked),\n\t * rootShapeIds: content.rootShapeIds.filter(id =>\n\t * content.shapes.find(s => s.id === id && !s.meta.locked)\n\t * ),\n\t * }\n\t * }\n\t * ```\n\t */\n\tonBeforeCopyToClipboard?(\n\t\tinfo: { editor: Editor; content: TLContent } & TLClipboardWriteInfo\n\t): Awaitable<TLContent | false | void>\n\t/**\n\t * Called before pasted content is processed and shapes are created. Receives the parsed\n\t * external content from the clipboard and can filter, transform, or cancel it.\n\t *\n\t * Return `false` to cancel the paste. Return a modified content object to transform it.\n\t * Return `void` (or `undefined`) to pass through unchanged. You may return a `Promise` of\n\t * those values if the hook is async.\n\t *\n\t * This only fires for clipboard paste operations (keyboard shortcuts and menu actions),\n\t * not for file drops or programmatic `putExternalContent` calls.\n\t *\n\t * @example\n\t * ```tsx\n\t * // Block pasting of image files\n\t * onBeforePasteFromClipboard({ content }) {\n\t * if (content.type === 'files') {\n\t * const nonImages = content.files.filter(f => !f.type.startsWith('image/'))\n\t * if (nonImages.length === 0) return false\n\t * return { ...content, files: nonImages }\n\t * }\n\t * }\n\t * ```\n\t */\n\tonBeforePasteFromClipboard?(info: {\n\t\teditor: Editor\n\t\tcontent: TLExternalContent<unknown>\n\t\tsource: 'native-event' | 'clipboard-read'\n\t\tpoint?: VecLike\n\t}): Awaitable<TLExternalContent<unknown> | false | void>\n\t/**\n\t * Called first for keyboard and menu paste, **before** tldraw handles or parses clipboard data\n\t * (and before {@link TldrawOptions.onBeforePasteFromClipboard}).\n\t *\n\t * Return `false` to cancel tldraw's default paste handling for this gesture (same convention as\n\t * {@link TldrawOptions.onBeforePasteFromClipboard}). Use this when you handle paste yourself from\n\t * raw clipboard data, or to block the gesture entirely. Return `void` (or `undefined`) to continue.\n\t */\n\tonClipboardPasteRaw?(info: TLClipboardPasteRawInfo): false | void\n\t/**\n\t * Called when content is dropped on the canvas. Provides the page position\n\t * where the drop occurred and the underlying drag event object.\n\t * Return true to prevent default drop handling (files, URLs, etc.)\n\t */\n\texperimental__onDropOnCanvas?(options: {\n\t\tpoint: VecLike\n\t\tevent: React.DragEvent<Element>\n\t}): boolean\n}\n\n/** @public */\nexport const defaultTldrawOptions = {\n\tmaxShapesPerPage: 4000,\n\tmaxFilesAtOnce: 100,\n\tmaxPages: 40,\n\tanimationMediumMs: 320,\n\tfollowChaseViewportSnap: 2,\n\tdoubleClickDurationMs: 450,\n\tmultiClickDurationMs: 200,\n\tcoarseDragDistanceSquared: 36, // 6 squared\n\tdragDistanceSquared: 16, // 4 squared\n\tuiDragDistanceSquared: 16, // 4 squared\n\t// it's really easy to accidentally drag from the toolbar on mobile, so we use a much larger\n\t// threshold than usual here to try and prevent accidental drags.\n\tuiCoarseDragDistanceSquared: 625, // 25 squared\n\tdefaultSvgPadding: 32,\n\tcameraSlideFriction: 0.09,\n\tgridSteps: [\n\t\t{ min: -1, mid: 0.15, step: 64 },\n\t\t{ min: 0.05, mid: 0.375, step: 16 },\n\t\t{ min: 0.15, mid: 1, step: 4 },\n\t\t{ min: 0.7, mid: 2.5, step: 1 },\n\t],\n\tcollaboratorInactiveTimeoutMs: 60000,\n\tcollaboratorIdleTimeoutMs: 3000,\n\tcollaboratorCheckIntervalMs: 1200,\n\tcameraMovingTimeoutMs: 64,\n\thitTestMargin: 8,\n\tedgeScrollDelay: 200,\n\tedgeScrollEaseDuration: 200,\n\tedgeScrollSpeed: 25,\n\tedgeScrollDistance: 8,\n\tcoarsePointerWidth: 12,\n\tcoarseHandleRadius: 20,\n\thandleRadius: 12,\n\tlongPressDurationMs: 500,\n\ttextShadowLod: 0.35,\n\tadjacentShapeMargin: 10,\n\tflattenImageBoundsExpand: 64,\n\tflattenImageBoundsPadding: 16,\n\tlaserDelayMs: 1200,\n\tlaserFadeoutMs: 500,\n\tmaxExportDelayMs: 5000,\n\ttooltipDelayMs: 700,\n\ttemporaryAssetPreviewLifetimeMs: 180000,\n\tactionShortcutsLocation: 'swap',\n\tcreateTextOnCanvasDoubleClick: true,\n\texportProvider: Fragment,\n\tenableToolbarKeyboardShortcuts: true,\n\tmaxFontsToLoadBeforeRender: Infinity,\n\tnonce: undefined,\n\tdebouncedZoom: true,\n\tdebouncedZoomThreshold: 500,\n\tspacebarPanning: true,\n\trightClickPanning: true,\n\tzoomToFitPadding: 128,\n\tsnapThreshold: 8,\n\tselectLockedShapes: false,\n\tcamera: DEFAULT_CAMERA_OPTIONS,\n\ttext: {},\n\tdeepLinks: undefined,\n\tquickZoomPreservesScreenBounds: true,\n\tonBeforeCopyToClipboard: undefined,\n\tonBeforePasteFromClipboard: undefined,\n\tonClipboardPasteRaw: undefined,\n\texperimental__onDropOnCanvas: undefined,\n} as const satisfies TldrawOptions\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAwC;AACxC,uBAAuC;
|
|
4
|
+
"sourcesContent": ["import { Awaitable } from '@tldraw/utils'\nimport { ComponentType, Fragment } from 'react'\nimport { DEFAULT_CAMERA_OPTIONS } from './constants'\nimport type { Editor } from './editor/Editor'\nimport { TLContent } from './editor/types/clipboard-types'\nimport { TLExternalContent } from './editor/types/external-content'\nimport { TLCameraOptions } from './editor/types/misc-types'\nimport { VecLike } from './primitives/Vec'\nimport { TLDeepLinkOptions } from './utils/deepLinks'\nimport { TLTextOptions } from './utils/richText'\n\n/**\n * Identifies how a clipboard write was triggered (copy vs cut, keyboard vs menu).\n *\n * @public\n */\nexport interface TLClipboardWriteInfo {\n\treadonly operation: 'copy' | 'cut'\n\treadonly source: 'native' | 'menu'\n}\n\n/**\n * Raw clipboard paste payload, before tldraw parses clipboard contents into {@link TLExternalContent}.\n *\n * - `native-event`: from the `paste` event \u2014 `clipboardData` is available synchronously (unlike async\n * `navigator.clipboard.read()`).\n * - `clipboard-read`: from an explicit `navigator.clipboard.read()` call \u2014 only `ClipboardItem[]`\n * exists\n * (no `DataTransfer`).\n *\n * @public\n */\nexport type TLClipboardPasteRawInfo =\n\t| {\n\t\t\treadonly editor: Editor\n\t\t\treadonly source: 'native-event'\n\t\t\treadonly event: ClipboardEvent\n\t\t\treadonly clipboardData: DataTransfer | null\n\t\t\treadonly point: VecLike | undefined\n\t }\n\t| {\n\t\t\treadonly editor: Editor\n\t\t\treadonly source: 'clipboard-read'\n\t\t\treadonly clipboardItems: readonly ClipboardItem[]\n\t\t\treadonly point: VecLike | undefined\n\t }\n\n/**\n * Options for configuring tldraw. For defaults, see {@link defaultTldrawOptions}.\n *\n * @example\n * ```tsx\n * const options: Partial<TldrawOptions> = {\n * maxPages: 3,\n * maxShapesPerPage: 1000,\n * }\n *\n * function MyTldrawComponent() {\n * return <Tldraw options={options} />\n * }\n * ```\n *\n * @public\n */\nexport interface TldrawOptions {\n\treadonly maxShapesPerPage: number\n\treadonly maxFilesAtOnce: number\n\treadonly maxPages: number\n\treadonly animationMediumMs: number\n\treadonly followChaseViewportSnap: number\n\treadonly doubleClickDurationMs: number\n\treadonly multiClickDurationMs: number\n\treadonly coarseDragDistanceSquared: number\n\treadonly dragDistanceSquared: number\n\treadonly uiDragDistanceSquared: number\n\treadonly uiCoarseDragDistanceSquared: number\n\treadonly defaultSvgPadding: number\n\treadonly cameraSlideFriction: number\n\treadonly gridSteps: readonly {\n\t\treadonly min: number\n\t\treadonly mid: number\n\t\treadonly step: number\n\t}[]\n\treadonly collaboratorInactiveTimeoutMs: number\n\treadonly collaboratorIdleTimeoutMs: number\n\treadonly collaboratorCheckIntervalMs: number\n\treadonly cameraMovingTimeoutMs: number\n\treadonly hitTestMargin: number\n\treadonly coarseHitTestMargin: number\n\treadonly edgeScrollDelay: number\n\treadonly edgeScrollEaseDuration: number\n\treadonly edgeScrollSpeed: number\n\treadonly edgeScrollDistance: number\n\treadonly coarsePointerWidth: number\n\treadonly coarseHandleRadius: number\n\treadonly handleRadius: number\n\treadonly longPressDurationMs: number\n\treadonly textShadowLod: number\n\treadonly adjacentShapeMargin: number\n\treadonly flattenImageBoundsExpand: number\n\treadonly flattenImageBoundsPadding: number\n\treadonly laserDelayMs: number\n\t/**\n\t * How long (in milliseconds) to fade all laser scribbles after the session ends.\n\t * The total points across all scribbles will be removed proportionally over this duration.\n\t * Defaults to 500ms (0.5 seconds).\n\t */\n\treadonly laserFadeoutMs: number\n\treadonly maxExportDelayMs: number\n\treadonly tooltipDelayMs: number\n\t/**\n\t * How long should previews created by {@link Editor.createTemporaryAssetPreview} last before\n\t * they expire? Defaults to 3 minutes.\n\t */\n\treadonly temporaryAssetPreviewLifetimeMs: number\n\treadonly actionShortcutsLocation: 'menu' | 'toolbar' | 'swap'\n\treadonly createTextOnCanvasDoubleClick: boolean\n\t/**\n\t * The react provider to use when exporting an image. This is useful if your shapes depend on\n\t * external context providers. By default, this is `React.Fragment`.\n\t */\n\treadonly exportProvider: ComponentType<{ children: React.ReactNode }>\n\t/**\n\t * By default, the toolbar items are accessible via number shortcuts according to their order. To disable this, set this option to false.\n\t */\n\treadonly enableToolbarKeyboardShortcuts: boolean\n\t/**\n\t * The maximum number of fonts that will be loaded while blocking the main rendering of the\n\t * canvas. If there are more than this number of fonts needed, we'll just show the canvas right\n\t * away and let the fonts load in in the background.\n\t */\n\treadonly maxFontsToLoadBeforeRender: number\n\t/**\n\t * If you have a CSP policy that blocks inline styles, you can use this prop to provide a\n\t * nonce to use in the editor's styles.\n\t */\n\treadonly nonce: string | undefined\n\t/**\n\t * Branding name of the app, currently only used for adding aria-label for the application.\n\t */\n\treadonly branding?: string\n\t/**\n\t * Whether to use debounced zoom level for certain rendering optimizations. When true,\n\t * `editor.getEfficientZoomLevel()` returns a cached zoom value while the camera is moving,\n\t * reducing re-renders. When false, it always returns the current zoom level.\n\t */\n\treadonly debouncedZoom: boolean\n\t/**\n\t * The number of shapes that must be on the page for the debounced zoom level to be used.\n\t * Defaults to 500 shapes.\n\t */\n\treadonly debouncedZoomThreshold: number\n\t/**\n\t * Whether to allow spacebar panning. When true, the spacebar will pan the camera when held down.\n\t * When false, the spacebar will not pan the camera.\n\t */\n\treadonly spacebarPanning: boolean\n\t/**\n\t * Whether to allow right-click + drag to pan the camera. When true, right-click + drag pans the\n\t * camera and a static right-click opens the context menu at the release position. When false,\n\t * right-click opens the context menu on press (no drag-to-pan).\n\t */\n\treadonly rightClickPanning: boolean\n\t/**\n\t * The default padding (in pixels) used when zooming to fit content in the viewport.\n\t * This affects methods like `zoomToFit()`, `zoomToSelection()`, and `zoomToBounds()`.\n\t * The actual padding used is the minimum of this value and 28% of the viewport width.\n\t * Defaults to 128 pixels.\n\t */\n\treadonly zoomToFitPadding: number\n\t/**\n\t * The distance (in screen pixels) at which shapes snap to guides and other shapes.\n\t */\n\treadonly snapThreshold: number\n\t/**\n\t * Whether locked shapes can be selected with a left click. When false (default), left-clicking\n\t * a locked shape is treated as a click on the canvas \u2014 only right-click selects it. When true,\n\t * locked shapes can be selected via left click and included in brush and scribble selections,\n\t * but the editor's lock guards still prevent moving, resizing, editing, or deleting them.\n\t */\n\treadonly selectLockedShapes: boolean\n\t/**\n\t * Options for the editor's camera. These are the initial camera options.\n\t * Use {@link Editor.setCameraOptions} to update camera options at runtime.\n\t */\n\treadonly camera: Partial<TLCameraOptions>\n\t/**\n\t * Options for the editor's text rendering. These include TipTap configuration and\n\t * font handling. These are the initial text options and cannot be changed at runtime.\n\t */\n\treadonly text: TLTextOptions\n\t/**\n\t * Options for syncing the editor's camera state with the URL. Set to `true` to enable\n\t * with default options, or pass an options object to customize behavior.\n\t *\n\t * @example\n\t * ```tsx\n\t * // Enable with defaults\n\t * <Tldraw options={{ deepLinks: true }} />\n\t *\n\t * // Enable with custom options\n\t * <Tldraw options={{ deepLinks: { param: 'd', debounceMs: 500 } }} />\n\t * ```\n\t */\n\treadonly deepLinks: true | TLDeepLinkOptions | undefined\n\t/**\n\t * Whether the quick-zoom brush preserves its screen-pixel size when the user\n\t * zooms the overview. When true, zooming in shrinks the target viewport (higher\n\t * return zoom); zooming out expands it. When false, the brush keeps the original\n\t * viewport's page dimensions regardless of overview zoom changes.\n\t */\n\treadonly quickZoomPreservesScreenBounds: boolean\n\t/**\n\t * Called before content is written to the clipboard during a copy or cut operation.\n\t * Receives the serialized content (shapes, bindings, assets) and can filter or transform\n\t * it before it reaches the clipboard.\n\t *\n\t * Return a modified `TLContent` object to change what is copied or cut. Return `false` to\n\t * cancel the clipboard write (for cut, the selected shapes are not removed). Return `void`\n\t * (or `undefined`) to pass through unchanged. You may return a `Promise` of those values if\n\t * the hook is async.\n\t *\n\t * @example\n\t * ```tsx\n\t * // Filter out \"locked\" shapes from copy\n\t * onBeforeCopyToClipboard({ content, operation }) {\n\t * return {\n\t * ...content,\n\t * shapes: content.shapes.filter(s => !s.meta.locked),\n\t * rootShapeIds: content.rootShapeIds.filter(id =>\n\t * content.shapes.find(s => s.id === id && !s.meta.locked)\n\t * ),\n\t * }\n\t * }\n\t * ```\n\t */\n\tonBeforeCopyToClipboard?(\n\t\tinfo: { editor: Editor; content: TLContent } & TLClipboardWriteInfo\n\t): Awaitable<TLContent | false | void>\n\t/**\n\t * Called before pasted content is processed and shapes are created. Receives the parsed\n\t * external content from the clipboard and can filter, transform, or cancel it.\n\t *\n\t * Return `false` to cancel the paste. Return a modified content object to transform it.\n\t * Return `void` (or `undefined`) to pass through unchanged. You may return a `Promise` of\n\t * those values if the hook is async.\n\t *\n\t * This only fires for clipboard paste operations (keyboard shortcuts and menu actions),\n\t * not for file drops or programmatic `putExternalContent` calls.\n\t *\n\t * @example\n\t * ```tsx\n\t * // Block pasting of image files\n\t * onBeforePasteFromClipboard({ content }) {\n\t * if (content.type === 'files') {\n\t * const nonImages = content.files.filter(f => !f.type.startsWith('image/'))\n\t * if (nonImages.length === 0) return false\n\t * return { ...content, files: nonImages }\n\t * }\n\t * }\n\t * ```\n\t */\n\tonBeforePasteFromClipboard?(info: {\n\t\teditor: Editor\n\t\tcontent: TLExternalContent<unknown>\n\t\tsource: 'native-event' | 'clipboard-read'\n\t\tpoint?: VecLike\n\t}): Awaitable<TLExternalContent<unknown> | false | void>\n\t/**\n\t * Called first for keyboard and menu paste, **before** tldraw handles or parses clipboard data\n\t * (and before {@link TldrawOptions.onBeforePasteFromClipboard}).\n\t *\n\t * Return `false` to cancel tldraw's default paste handling for this gesture (same convention as\n\t * {@link TldrawOptions.onBeforePasteFromClipboard}). Use this when you handle paste yourself from\n\t * raw clipboard data, or to block the gesture entirely. Return `void` (or `undefined`) to continue.\n\t */\n\tonClipboardPasteRaw?(info: TLClipboardPasteRawInfo): false | void\n\t/**\n\t * Called when content is dropped on the canvas. Provides the page position\n\t * where the drop occurred and the underlying drag event object.\n\t * Return true to prevent default drop handling (files, URLs, etc.)\n\t */\n\texperimental__onDropOnCanvas?(options: {\n\t\tpoint: VecLike\n\t\tevent: React.DragEvent<Element>\n\t}): boolean\n}\n\n/** @public */\nexport const defaultTldrawOptions = {\n\tmaxShapesPerPage: 4000,\n\tmaxFilesAtOnce: 100,\n\tmaxPages: 40,\n\tanimationMediumMs: 320,\n\tfollowChaseViewportSnap: 2,\n\tdoubleClickDurationMs: 450,\n\tmultiClickDurationMs: 200,\n\tcoarseDragDistanceSquared: 36, // 6 squared\n\tdragDistanceSquared: 16, // 4 squared\n\tuiDragDistanceSquared: 16, // 4 squared\n\t// it's really easy to accidentally drag from the toolbar on mobile, so we use a much larger\n\t// threshold than usual here to try and prevent accidental drags.\n\tuiCoarseDragDistanceSquared: 625, // 25 squared\n\tdefaultSvgPadding: 32,\n\tcameraSlideFriction: 0.09,\n\tgridSteps: [\n\t\t{ min: -1, mid: 0.15, step: 64 },\n\t\t{ min: 0.05, mid: 0.375, step: 16 },\n\t\t{ min: 0.15, mid: 1, step: 4 },\n\t\t{ min: 0.7, mid: 2.5, step: 1 },\n\t],\n\tcollaboratorInactiveTimeoutMs: 60000,\n\tcollaboratorIdleTimeoutMs: 3000,\n\tcollaboratorCheckIntervalMs: 1200,\n\tcameraMovingTimeoutMs: 64,\n\thitTestMargin: 3,\n\tcoarseHitTestMargin: 4,\n\tedgeScrollDelay: 200,\n\tedgeScrollEaseDuration: 200,\n\tedgeScrollSpeed: 25,\n\tedgeScrollDistance: 8,\n\tcoarsePointerWidth: 12,\n\tcoarseHandleRadius: 20,\n\thandleRadius: 12,\n\tlongPressDurationMs: 500,\n\ttextShadowLod: 0.35,\n\tadjacentShapeMargin: 10,\n\tflattenImageBoundsExpand: 64,\n\tflattenImageBoundsPadding: 16,\n\tlaserDelayMs: 1200,\n\tlaserFadeoutMs: 500,\n\tmaxExportDelayMs: 5000,\n\ttooltipDelayMs: 700,\n\ttemporaryAssetPreviewLifetimeMs: 180000,\n\tactionShortcutsLocation: 'swap',\n\tcreateTextOnCanvasDoubleClick: true,\n\texportProvider: Fragment,\n\tenableToolbarKeyboardShortcuts: true,\n\tmaxFontsToLoadBeforeRender: Infinity,\n\tnonce: undefined,\n\tdebouncedZoom: true,\n\tdebouncedZoomThreshold: 500,\n\tspacebarPanning: true,\n\trightClickPanning: true,\n\tzoomToFitPadding: 128,\n\tsnapThreshold: 8,\n\tselectLockedShapes: false,\n\tcamera: DEFAULT_CAMERA_OPTIONS,\n\ttext: {},\n\tdeepLinks: undefined,\n\tquickZoomPreservesScreenBounds: true,\n\tonBeforeCopyToClipboard: undefined,\n\tonBeforePasteFromClipboard: undefined,\n\tonClipboardPasteRaw: undefined,\n\texperimental__onDropOnCanvas: undefined,\n} as const satisfies TldrawOptions\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAwC;AACxC,uBAAuC;AA+RhC,MAAM,uBAAuB;AAAA,EACnC,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,UAAU;AAAA,EACV,mBAAmB;AAAA,EACnB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,sBAAsB;AAAA,EACtB,2BAA2B;AAAA;AAAA,EAC3B,qBAAqB;AAAA;AAAA,EACrB,uBAAuB;AAAA;AAAA;AAAA;AAAA,EAGvB,6BAA6B;AAAA;AAAA,EAC7B,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,WAAW;AAAA,IACV,EAAE,KAAK,IAAI,KAAK,MAAM,MAAM,GAAG;AAAA,IAC/B,EAAE,KAAK,MAAM,KAAK,OAAO,MAAM,GAAG;AAAA,IAClC,EAAE,KAAK,MAAM,KAAK,GAAG,MAAM,EAAE;AAAA,IAC7B,EAAE,KAAK,KAAK,KAAK,KAAK,MAAM,EAAE;AAAA,EAC/B;AAAA,EACA,+BAA+B;AAAA,EAC/B,2BAA2B;AAAA,EAC3B,6BAA6B;AAAA,EAC7B,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,0BAA0B;AAAA,EAC1B,2BAA2B;AAAA,EAC3B,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,iCAAiC;AAAA,EACjC,yBAAyB;AAAA,EACzB,+BAA+B;AAAA,EAC/B,gBAAgB;AAAA,EAChB,gCAAgC;AAAA,EAChC,4BAA4B;AAAA,EAC5B,OAAO;AAAA,EACP,eAAe;AAAA,EACf,wBAAwB;AAAA,EACxB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,QAAQ;AAAA,EACR,MAAM,CAAC;AAAA,EACP,WAAW;AAAA,EACX,gCAAgC;AAAA,EAChC,yBAAyB;AAAA,EACzB,4BAA4B;AAAA,EAC5B,qBAAqB;AAAA,EACrB,8BAA8B;AAC/B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var collaborators_exports = {};
|
|
20
|
+
__export(collaborators_exports, {
|
|
21
|
+
isCursorInViewport: () => isCursorInViewport
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(collaborators_exports);
|
|
24
|
+
function isCursorInViewport(cursor, viewport, zoom) {
|
|
25
|
+
return !(cursor.x < viewport.minX - 12 / zoom || cursor.y < viewport.minY - 16 / zoom || cursor.x > viewport.maxX - 12 / zoom || cursor.y > viewport.maxY - 16 / zoom);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=collaborators.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/utils/collaborators.ts"],
|
|
4
|
+
"sourcesContent": ["import { VecLike } from '../primitives/Vec'\n\n/**\n * Whether a collaborator's cursor (page coords) is inside the viewport, with a small margin for the\n * cursor glyph so it isn't culled the instant its hotspot crosses the edge.\n *\n * Single source of truth for the cursor/hint split: the DOM cursor layer renders a collaborator\n * when this is true, and `CollaboratorHintOverlayUtil` draws the viewport-edge hint when it's\n * false. Sharing the predicate keeps those two exhaustive and mutually exclusive \u2014 a margin change\n * can't open a dead zone (neither renders) or a double-render (both).\n *\n * @public\n */\nexport function isCursorInViewport(\n\tcursor: VecLike,\n\tviewport: { minX: number; minY: number; maxX: number; maxY: number },\n\tzoom: number\n): boolean {\n\treturn !(\n\t\tcursor.x < viewport.minX - 12 / zoom ||\n\t\tcursor.y < viewport.minY - 16 / zoom ||\n\t\tcursor.x > viewport.maxX - 12 / zoom ||\n\t\tcursor.y > viewport.maxY - 16 / zoom\n\t)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,mBACf,QACA,UACA,MACU;AACV,SAAO,EACN,OAAO,IAAI,SAAS,OAAO,KAAK,QAChC,OAAO,IAAI,SAAS,OAAO,KAAK,QAChC,OAAO,IAAI,SAAS,OAAO,KAAK,QAChC,OAAO,IAAI,SAAS,OAAO,KAAK;AAElC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var getHtmlLayerTransform_exports = {};
|
|
20
|
+
__export(getHtmlLayerTransform_exports, {
|
|
21
|
+
getHtmlLayerTransform: () => getHtmlLayerTransform
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(getHtmlLayerTransform_exports);
|
|
24
|
+
var import_utils = require("@tldraw/utils");
|
|
25
|
+
var import_utils2 = require("../primitives/utils");
|
|
26
|
+
function getHtmlLayerTransform(editor) {
|
|
27
|
+
const { x, y, z } = editor.getCamera();
|
|
28
|
+
const offset = z >= 1 ? (0, import_utils.modulate)(z, [1, 8], [0.125, 0.5], true) : (0, import_utils.modulate)(z, [0.1, 1], [-2, 0.125], true);
|
|
29
|
+
return `scale(${(0, import_utils2.toDomPrecision)(z)}) translate(${(0, import_utils2.toDomPrecision)(x + offset)}px,${(0, import_utils2.toDomPrecision)(
|
|
30
|
+
y + offset
|
|
31
|
+
)}px)`;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=getHtmlLayerTransform.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/utils/getHtmlLayerTransform.ts"],
|
|
4
|
+
"sourcesContent": ["import { modulate } from '@tldraw/utils'\nimport type { Editor } from '../editor/Editor'\nimport { toDomPrecision } from '../primitives/utils'\n\n/**\n * The CSS `transform` that puts a 1px-sized html layer into page space under the current camera.\n * Shared by every camera-tracked DOM layer (the canvas's shape layer, the collaborator cursor\n * layer) so they line up exactly and can't drift apart.\n *\n * The offset compensates for the layer's 1px width/height when zoomed, so it registers precisely\n * with the other layers.\n *\n * @internal\n */\nexport function getHtmlLayerTransform(editor: Editor): string {\n\tconst { x, y, z } = editor.getCamera()\n\tconst offset =\n\t\tz >= 1 ? modulate(z, [1, 8], [0.125, 0.5], true) : modulate(z, [0.1, 1], [-2, 0.125], true)\n\treturn `scale(${toDomPrecision(z)}) translate(${toDomPrecision(x + offset)}px,${toDomPrecision(\n\t\ty + offset\n\t)}px)`\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyB;AAEzB,IAAAA,gBAA+B;AAYxB,SAAS,sBAAsB,QAAwB;AAC7D,QAAM,EAAE,GAAG,GAAG,EAAE,IAAI,OAAO,UAAU;AACrC,QAAM,SACL,KAAK,QAAI,uBAAS,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,GAAG,GAAG,IAAI,QAAI,uBAAS,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,GAAG,IAAI;AAC3F,SAAO,aAAS,8BAAe,CAAC,CAAC,mBAAe,8BAAe,IAAI,MAAM,CAAC,UAAM;AAAA,IAC/E,IAAI;AAAA,EACL,CAAC;AACF;",
|
|
6
|
+
"names": ["import_utils"]
|
|
7
|
+
}
|
package/dist-cjs/version.js
CHANGED
|
@@ -22,10 +22,10 @@ __export(version_exports, {
|
|
|
22
22
|
version: () => version
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(version_exports);
|
|
25
|
-
const version = "5.3.0-canary.
|
|
25
|
+
const version = "5.3.0-canary.dee64fee16b5";
|
|
26
26
|
const publishDates = {
|
|
27
27
|
major: "2026-05-06T16:28:18.473Z",
|
|
28
|
-
minor: "2026-
|
|
29
|
-
patch: "2026-
|
|
28
|
+
minor: "2026-08-05T08:09:53.420Z",
|
|
29
|
+
patch: "2026-08-05T08:09:53.420Z"
|
|
30
30
|
};
|
|
31
31
|
//# sourceMappingURL=version.js.map
|
package/dist-cjs/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/version.ts"],
|
|
4
|
-
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '5.3.0-canary.
|
|
4
|
+
"sourcesContent": ["// This file is automatically generated by internal/scripts/refresh-assets.ts.\n// Do not edit manually. Or do, I'm a comment, not a cop.\n\nexport const version = '5.3.0-canary.dee64fee16b5'\nexport const publishDates = {\n\tmajor: '2026-05-06T16:28:18.473Z',\n\tminor: '2026-08-05T08:09:53.420Z',\n\tpatch: '2026-08-05T08:09:53.420Z',\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,UAAU;AAChB,MAAM,eAAe;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist-esm/index.d.mts
CHANGED
|
@@ -19,12 +19,14 @@ import { JsonObject } from '@tldraw/utils';
|
|
|
19
19
|
import { JSX } from 'react/jsx-runtime';
|
|
20
20
|
import { LegacyMigrations } from '@tldraw/store';
|
|
21
21
|
import { MigrationSequence } from '@tldraw/store';
|
|
22
|
+
import { NamedExoticComponent } from 'react';
|
|
22
23
|
import { Node as Node_2 } from '@tiptap/pm/model';
|
|
23
24
|
import { PerformanceTracker } from '@tldraw/utils';
|
|
24
25
|
import * as React_2 from 'react';
|
|
25
26
|
import { default as React_3 } from 'react';
|
|
26
27
|
import { ReactElement } from 'react';
|
|
27
28
|
import { ReactNode } from 'react';
|
|
29
|
+
import { ReactPortal } from 'react';
|
|
28
30
|
import { RecordProps } from '@tldraw/tlschema';
|
|
29
31
|
import { RecordsDiff } from '@tldraw/store';
|
|
30
32
|
import { RefAttributes } from 'react';
|
|
@@ -982,6 +984,15 @@ export declare function DefaultBackground(): JSX.Element;
|
|
|
982
984
|
/** @public @react */
|
|
983
985
|
export declare function DefaultCanvas({ className }: TLCanvasComponentProps): JSX.Element;
|
|
984
986
|
|
|
987
|
+
/**
|
|
988
|
+
* The default collaborator cursor: the arrow glyph plus a name tag or chat bubble. The arrow is a
|
|
989
|
+
* `<use>` of a shared `<defs>` symbol that `LiveCollaborators` renders, so a `DefaultCursor`
|
|
990
|
+
* used outside that layer draws no arrow.
|
|
991
|
+
*
|
|
992
|
+
* @public @react
|
|
993
|
+
*/
|
|
994
|
+
export declare const DefaultCursor: NamedExoticComponent<TLCursorProps>;
|
|
995
|
+
|
|
985
996
|
/** @public @react */
|
|
986
997
|
export declare const DefaultErrorFallback: TLErrorFallbackComponent;
|
|
987
998
|
|
|
@@ -1007,6 +1018,7 @@ export declare const defaultTldrawOptions: {
|
|
|
1007
1018
|
readonly cameraSlideFriction: 0.09;
|
|
1008
1019
|
readonly coarseDragDistanceSquared: 36;
|
|
1009
1020
|
readonly coarseHandleRadius: 20;
|
|
1021
|
+
readonly coarseHitTestMargin: 4;
|
|
1010
1022
|
readonly coarsePointerWidth: 12;
|
|
1011
1023
|
readonly collaboratorCheckIntervalMs: 1200;
|
|
1012
1024
|
readonly collaboratorIdleTimeoutMs: 3000;
|
|
@@ -1046,7 +1058,7 @@ export declare const defaultTldrawOptions: {
|
|
|
1046
1058
|
readonly step: 1;
|
|
1047
1059
|
}];
|
|
1048
1060
|
readonly handleRadius: 12;
|
|
1049
|
-
readonly hitTestMargin:
|
|
1061
|
+
readonly hitTestMargin: 3;
|
|
1050
1062
|
readonly laserDelayMs: 1200;
|
|
1051
1063
|
readonly laserFadeoutMs: 500;
|
|
1052
1064
|
readonly longPressDurationMs: 500;
|
|
@@ -1220,12 +1232,19 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1220
1232
|
* @public
|
|
1221
1233
|
*/
|
|
1222
1234
|
isDisposed: boolean;
|
|
1235
|
+
private readonly _isMounted;
|
|
1223
1236
|
/**
|
|
1224
|
-
* Whether the editor is mounted.
|
|
1237
|
+
* Whether the editor is currently mounted. This is `true` while the editor's component is
|
|
1238
|
+
* mounted in the DOM (after the `mount` event) and `false` before mount and after `unmount`.
|
|
1239
|
+
*
|
|
1240
|
+
* Unlike disposal, mounting is not terminal: the editor's component can unmount and remount
|
|
1241
|
+
* (for example when the canvas is replaced by an error fallback and restored) without the
|
|
1242
|
+
* editor itself being disposed. To react to the transitions, listen to the editor's `mount`
|
|
1243
|
+
* and `unmount` events.
|
|
1225
1244
|
*
|
|
1226
1245
|
* @public
|
|
1227
1246
|
*/
|
|
1228
|
-
|
|
1247
|
+
getIsMounted(): boolean;
|
|
1229
1248
|
/* Excluded from this release type: _tickManager */
|
|
1230
1249
|
/**
|
|
1231
1250
|
* A manager for the editor's input state.
|
|
@@ -3094,6 +3113,17 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
3094
3113
|
* @public
|
|
3095
3114
|
*/
|
|
3096
3115
|
getCurrentPageBounds(): Box | undefined;
|
|
3116
|
+
/**
|
|
3117
|
+
* Get the hit-test margin in page space—the distance in page units within which a pointer is
|
|
3118
|
+
* considered to be touching a shape. This resolves to {@link TldrawOptions.hitTestMargin} (or
|
|
3119
|
+
* {@link TldrawOptions.coarseHitTestMargin} when using a coarse pointer) divided by the current
|
|
3120
|
+
* zoom level, so it stays a constant distance in screen space.
|
|
3121
|
+
*
|
|
3122
|
+
* @returns The hit-test margin in page space.
|
|
3123
|
+
*
|
|
3124
|
+
* @public
|
|
3125
|
+
*/
|
|
3126
|
+
getHitTestMargin(): number;
|
|
3097
3127
|
/**
|
|
3098
3128
|
* Get the top-most selected shape at the given point, ignoring groups.
|
|
3099
3129
|
*
|
|
@@ -4567,6 +4597,52 @@ export declare abstract class EditorManager {
|
|
|
4567
4597
|
/* Excluded from this release type: dispose */
|
|
4568
4598
|
}
|
|
4569
4599
|
|
|
4600
|
+
/**
|
|
4601
|
+
* Renders its children into the end of the editor's container, escaping the canvas layer.
|
|
4602
|
+
*
|
|
4603
|
+
* Use this for anything anchored to canvas coordinates that also has to draw over the UI — a
|
|
4604
|
+
* popover on a shape, a comment thread, an annotation panel. The `OnTheCanvas` and
|
|
4605
|
+
* `InFrontOfTheCanvas` slots are fixed layers, each its own stacking context, so content mounted
|
|
4606
|
+
* there can't paint above whatever outranks its layer whatever z-index it asks for. Mount in
|
|
4607
|
+
* whichever slot suits your data flow, wrap the part that needs its own layer in this, and give
|
|
4608
|
+
* that part a z-index.
|
|
4609
|
+
*
|
|
4610
|
+
* This package's own layers stop at 250 (`--tl-layer-canvas-in-front`); above that belongs to
|
|
4611
|
+
* whatever renders the UI. In `tldraw` that's `--tl-layer-panels` (300) and `--tl-layer-menus`
|
|
4612
|
+
* (400), defined by `tldraw`'s stylesheet rather than this one.
|
|
4613
|
+
*
|
|
4614
|
+
* Positioning still resolves against the editor's container, so a `position: absolute` child uses
|
|
4615
|
+
* ordinary container coordinates.
|
|
4616
|
+
*
|
|
4617
|
+
* Prefer this over `createPortal(children, useContainer())`, which picks its DOM position from the
|
|
4618
|
+
* commit that mounts it — landing the node ahead of the UI and of the "skip to main content" link
|
|
4619
|
+
* that only works while nothing precedes it. This host is a real element placed last, so ordering
|
|
4620
|
+
* is fixed rather than dependent on mount timing.
|
|
4621
|
+
*
|
|
4622
|
+
* @example
|
|
4623
|
+
* ```tsx
|
|
4624
|
+
* // 400 clears tldraw's menus layer; the bare editor's own layers stop at 250.
|
|
4625
|
+
* function ShapeAnnotation({ point }: { point: VecLike }) {
|
|
4626
|
+
* return (
|
|
4627
|
+
* <EditorPortal>
|
|
4628
|
+
* <div style={{ position: 'absolute', left: point.x, top: point.y, zIndex: 400 }}>
|
|
4629
|
+
* Above the UI
|
|
4630
|
+
* </div>
|
|
4631
|
+
* </EditorPortal>
|
|
4632
|
+
* )
|
|
4633
|
+
* }
|
|
4634
|
+
* ```
|
|
4635
|
+
*
|
|
4636
|
+
* @public
|
|
4637
|
+
* @react
|
|
4638
|
+
*/
|
|
4639
|
+
export declare function EditorPortal({ children }: EditorPortalProps): ReactPortal | null;
|
|
4640
|
+
|
|
4641
|
+
/** @public */
|
|
4642
|
+
export declare interface EditorPortalProps {
|
|
4643
|
+
children: ReactNode;
|
|
4644
|
+
}
|
|
4645
|
+
|
|
4570
4646
|
/** @public @react */
|
|
4571
4647
|
export declare function EditorProvider({ editor, children }: EditorProviderProps): JSX.Element;
|
|
4572
4648
|
|
|
@@ -5430,6 +5506,24 @@ export declare function intersectPolygonPolygon(polygonA: VecLike[], polygonB: V
|
|
|
5430
5506
|
|
|
5431
5507
|
/* Excluded from this release type: isAccelKey */
|
|
5432
5508
|
|
|
5509
|
+
/**
|
|
5510
|
+
* Whether a collaborator's cursor (page coords) is inside the viewport, with a small margin for the
|
|
5511
|
+
* cursor glyph so it isn't culled the instant its hotspot crosses the edge.
|
|
5512
|
+
*
|
|
5513
|
+
* Single source of truth for the cursor/hint split: the DOM cursor layer renders a collaborator
|
|
5514
|
+
* when this is true, and `CollaboratorHintOverlayUtil` draws the viewport-edge hint when it's
|
|
5515
|
+
* false. Sharing the predicate keeps those two exhaustive and mutually exclusive — a margin change
|
|
5516
|
+
* can't open a dead zone (neither renders) or a double-render (both).
|
|
5517
|
+
*
|
|
5518
|
+
* @public
|
|
5519
|
+
*/
|
|
5520
|
+
export declare function isCursorInViewport(cursor: VecLike, viewport: {
|
|
5521
|
+
maxX: number;
|
|
5522
|
+
maxY: number;
|
|
5523
|
+
minX: number;
|
|
5524
|
+
minY: number;
|
|
5525
|
+
}, zoom: number): boolean;
|
|
5526
|
+
|
|
5433
5527
|
/**
|
|
5434
5528
|
* Check if a float is safe to use. ie: Not too big or small.
|
|
5435
5529
|
* @public
|
|
@@ -5451,6 +5545,8 @@ export declare function kickoutOccludedShapes(editor: Editor, shapeIds: TLShapeI
|
|
|
5451
5545
|
|
|
5452
5546
|
/* Excluded from this release type: LICENSE_TIMEOUT */
|
|
5453
5547
|
|
|
5548
|
+
/* Excluded from this release type: LicenseFeatureName */
|
|
5549
|
+
|
|
5454
5550
|
/* Excluded from this release type: LicenseFromKeyResult */
|
|
5455
5551
|
|
|
5456
5552
|
/* Excluded from this release type: LicenseInfo */
|
|
@@ -6774,6 +6870,29 @@ export declare abstract class ShapeUtil<Shape extends TLShape = TLShape> {
|
|
|
6774
6870
|
* @public
|
|
6775
6871
|
*/
|
|
6776
6872
|
onBeforeCreate?(next: Shape): Shape | void;
|
|
6873
|
+
/**
|
|
6874
|
+
* A callback called when a shape is reproduced from an existing shape, either by duplicating
|
|
6875
|
+
* ({@link Editor.duplicateShapes}) or by pasting/putting content onto the page
|
|
6876
|
+
* ({@link Editor.putContentOntoCurrentPage}). This provides a last chance to modify the copy
|
|
6877
|
+
* before it's created — for example, to re-stamp attribution so the copy is credited to the
|
|
6878
|
+
* current user rather than the original author. It is not called when content is put with
|
|
6879
|
+
* `preserveIds` (e.g. {@link Editor.moveShapesToPage}), since the shape keeps its identity
|
|
6880
|
+
* and no copy is made.
|
|
6881
|
+
*
|
|
6882
|
+
* @example
|
|
6883
|
+
*
|
|
6884
|
+
* ```ts
|
|
6885
|
+
* onBeforeDuplicate = (source, duplicate) => {
|
|
6886
|
+
* return { ...duplicate, props: { ...duplicate.props, editedBy: this.editor.getAttributionUserId() } }
|
|
6887
|
+
* }
|
|
6888
|
+
* ```
|
|
6889
|
+
*
|
|
6890
|
+
* @param source - The shape being copied from.
|
|
6891
|
+
* @param duplicate - The new copy (with its own id), before it's created.
|
|
6892
|
+
* @returns The next shape or void.
|
|
6893
|
+
* @public
|
|
6894
|
+
*/
|
|
6895
|
+
onBeforeDuplicate?(source: Shape, duplicate: Shape): Shape | void;
|
|
6777
6896
|
/**
|
|
6778
6897
|
* A callback called just before a shape is updated. This method provides a last chance to modify
|
|
6779
6898
|
* the updated shape.
|
|
@@ -7506,6 +7625,11 @@ export declare interface TLBaseEventInfo {
|
|
|
7506
7625
|
|
|
7507
7626
|
/** @public */
|
|
7508
7627
|
export declare interface TLBaseExternalContent {
|
|
7628
|
+
/**
|
|
7629
|
+
* The other content sources found on the clipboard alongside this content. For example, when
|
|
7630
|
+
* pasting an image copied together with HTML and plain text, the `files` content will have
|
|
7631
|
+
* text sources for the HTML and plain text parts.
|
|
7632
|
+
*/
|
|
7509
7633
|
sources?: TLExternalContentSource[];
|
|
7510
7634
|
point?: VecLike;
|
|
7511
7635
|
}
|
|
@@ -7752,6 +7876,17 @@ export declare interface TLCurrentUser {
|
|
|
7752
7876
|
readonly setUserPreferences: (userPreferences: TLUserPreferences) => void;
|
|
7753
7877
|
}
|
|
7754
7878
|
|
|
7879
|
+
/** @public */
|
|
7880
|
+
export declare interface TLCursorProps {
|
|
7881
|
+
userId: string;
|
|
7882
|
+
className?: string;
|
|
7883
|
+
point: null | VecModel;
|
|
7884
|
+
zoom: number;
|
|
7885
|
+
color?: string;
|
|
7886
|
+
name: null | string;
|
|
7887
|
+
chatMessage: string;
|
|
7888
|
+
}
|
|
7889
|
+
|
|
7755
7890
|
/** @public */
|
|
7756
7891
|
export declare type TLDeepLink = {
|
|
7757
7892
|
bounds: BoxModel;
|
|
@@ -8040,6 +8175,7 @@ export declare interface TldrawOptions {
|
|
|
8040
8175
|
readonly collaboratorCheckIntervalMs: number;
|
|
8041
8176
|
readonly cameraMovingTimeoutMs: number;
|
|
8042
8177
|
readonly hitTestMargin: number;
|
|
8178
|
+
readonly coarseHitTestMargin: number;
|
|
8043
8179
|
readonly edgeScrollDelay: number;
|
|
8044
8180
|
readonly edgeScrollEaseDuration: number;
|
|
8045
8181
|
readonly edgeScrollSpeed: number;
|
|
@@ -8253,6 +8389,7 @@ export declare interface TLDropShapesOverInfo {
|
|
|
8253
8389
|
export declare interface TLEditorComponents {
|
|
8254
8390
|
Background?: ComponentType | null;
|
|
8255
8391
|
Canvas?: ComponentType<TLCanvasComponentProps> | null;
|
|
8392
|
+
CollaboratorCursor?: ComponentType<TLCursorProps> | null;
|
|
8256
8393
|
Grid?: ComponentType<TLGridProps> | null;
|
|
8257
8394
|
InFrontOfTheCanvas?: ComponentType | null;
|
|
8258
8395
|
LoadingScreen?: ComponentType | null;
|
|
@@ -8470,6 +8607,7 @@ export declare type TLEventInfo = TLCancelEventInfo | TLClickEventInfo | TLCompl
|
|
|
8470
8607
|
/** @public */
|
|
8471
8608
|
export declare interface TLEventMap {
|
|
8472
8609
|
mount: [];
|
|
8610
|
+
unmount: [];
|
|
8473
8611
|
'max-shapes': [{
|
|
8474
8612
|
count: number;
|
|
8475
8613
|
name: string;
|
|
@@ -9707,6 +9845,16 @@ export declare function useEditor(): Editor;
|
|
|
9707
9845
|
/** @public */
|
|
9708
9846
|
export declare function useEditorComponents(): Required<TLEditorComponents>;
|
|
9709
9847
|
|
|
9848
|
+
/**
|
|
9849
|
+
* The DOM node that {@link EditorPortal} renders into: an empty `display: contents` element the
|
|
9850
|
+
* editor renders last among its container's children, after the canvas and after the UI.
|
|
9851
|
+
*
|
|
9852
|
+
* Null until the container has mounted, so prefer {@link EditorPortal}, which handles that for you.
|
|
9853
|
+
*
|
|
9854
|
+
* @public
|
|
9855
|
+
*/
|
|
9856
|
+
export declare function useEditorPortalHost(): HTMLElement | null;
|
|
9857
|
+
|
|
9710
9858
|
/* Excluded from this release type: useEvent */
|
|
9711
9859
|
|
|
9712
9860
|
/** @public */
|
|
@@ -9718,6 +9866,10 @@ export declare function useIsCropping(shapeId: TLShapeId): boolean;
|
|
|
9718
9866
|
/** @public */
|
|
9719
9867
|
export declare function useIsEditing(shapeId: TLShapeId): boolean;
|
|
9720
9868
|
|
|
9869
|
+
/* Excluded from this release type: useLicenseContext */
|
|
9870
|
+
|
|
9871
|
+
/* Excluded from this release type: useLicenseFeatureFlag */
|
|
9872
|
+
|
|
9721
9873
|
/* Excluded from this release type: useLocalStore */
|
|
9722
9874
|
|
|
9723
9875
|
/** @public */
|
|
@@ -9725,9 +9877,6 @@ export declare function useMaybeEditor(): Editor | null;
|
|
|
9725
9877
|
|
|
9726
9878
|
/* Excluded from this release type: useOnMount */
|
|
9727
9879
|
|
|
9728
|
-
/** @public */
|
|
9729
|
-
export declare function usePassThroughMouseOverEvents(ref: RefObject<HTMLElement | null>): void;
|
|
9730
|
-
|
|
9731
9880
|
/** @public */
|
|
9732
9881
|
export declare function usePassThroughWheelEvents(ref: RefObject<HTMLElement | null>): void;
|
|
9733
9882
|
|
|
@@ -9854,6 +10003,13 @@ export declare function useTLSchemaFromUtils(opts: TLStoreSchemaOptions): StoreS
|
|
|
9854
10003
|
/** @public */
|
|
9855
10004
|
export declare function useTLStore(opts: TLStoreOptions): TLStore;
|
|
9856
10005
|
|
|
10006
|
+
/**
|
|
10007
|
+
* Position an element by writing its `transform` directly, outside React's render output — the
|
|
10008
|
+
* cheap path for elements that move at pointer/presence frequency.
|
|
10009
|
+
* @public
|
|
10010
|
+
*/
|
|
10011
|
+
export declare function useTransform(ref: React.RefObject<HTMLElement | null | SVGElement>, x?: number, y?: number, scale?: number, rotate?: number, additionalOffset?: VecLike): void;
|
|
10012
|
+
|
|
9857
10013
|
/**
|
|
9858
10014
|
* React's useId hook returns a unique id for the component. However, it uses a colon in the id,
|
|
9859
10015
|
* which is not valid for CSS selectors. This hook replaces the colon with an underscore.
|
|
@@ -9862,7 +10018,15 @@ export declare function useTLStore(opts: TLStoreOptions): TLStore;
|
|
|
9862
10018
|
*/
|
|
9863
10019
|
export declare function useUniqueSafeId(suffix?: string): SafeId;
|
|
9864
10020
|
|
|
9865
|
-
/**
|
|
10021
|
+
/**
|
|
10022
|
+
* The height of the visible viewport, including the visual viewport's own offset.
|
|
10023
|
+
*
|
|
10024
|
+
* @deprecated Read `window.visualViewport` directly: this flattens the visible rectangle to a
|
|
10025
|
+
* single scalar, and keeping UI clear of the software keyboard usually needs the other edges too.
|
|
10026
|
+
* Unused since v3.14; will be removed in a future release.
|
|
10027
|
+
*
|
|
10028
|
+
* @public
|
|
10029
|
+
*/
|
|
9866
10030
|
export declare function useViewportHeight(): number;
|
|
9867
10031
|
|
|
9868
10032
|
/* Excluded from this release type: ValidLicenseKeyResult */
|
package/dist-esm/index.mjs
CHANGED
|
@@ -9,6 +9,9 @@ import { DefaultBackground } from "./lib/components/default-components/DefaultBa
|
|
|
9
9
|
import {
|
|
10
10
|
DefaultCanvas
|
|
11
11
|
} from "./lib/components/default-components/DefaultCanvas.mjs";
|
|
12
|
+
import {
|
|
13
|
+
DefaultCursor
|
|
14
|
+
} from "./lib/components/default-components/DefaultCursor.mjs";
|
|
12
15
|
import {
|
|
13
16
|
DefaultErrorFallback
|
|
14
17
|
} from "./lib/components/default-components/DefaultErrorFallback.mjs";
|
|
@@ -18,6 +21,10 @@ import {
|
|
|
18
21
|
} from "./lib/components/default-components/DefaultShapeWrapper.mjs";
|
|
19
22
|
import { DefaultSpinner } from "./lib/components/default-components/DefaultSpinner.mjs";
|
|
20
23
|
import { DefaultSvgDefs } from "./lib/components/default-components/DefaultSvgDefs.mjs";
|
|
24
|
+
import {
|
|
25
|
+
EditorPortal,
|
|
26
|
+
useEditorPortalHost
|
|
27
|
+
} from "./lib/components/EditorPortal.mjs";
|
|
21
28
|
import {
|
|
22
29
|
ErrorBoundary,
|
|
23
30
|
OptionalErrorBoundary
|
|
@@ -144,7 +151,6 @@ import { useShallowArrayIdentity, useShallowObjectIdentity } from "./lib/hooks/u
|
|
|
144
151
|
import { useIsCropping } from "./lib/hooks/useIsCropping.mjs";
|
|
145
152
|
import { useIsEditing } from "./lib/hooks/useIsEditing.mjs";
|
|
146
153
|
import { useLocalStore } from "./lib/hooks/useLocalStore.mjs";
|
|
147
|
-
import { usePassThroughMouseOverEvents } from "./lib/hooks/usePassThroughMouseOverEvents.mjs";
|
|
148
154
|
import { usePassThroughWheelEvents } from "./lib/hooks/usePassThroughWheelEvents.mjs";
|
|
149
155
|
import { usePeerIds } from "./lib/hooks/usePeerIds.mjs";
|
|
150
156
|
import { usePresence } from "./lib/hooks/usePresence.mjs";
|
|
@@ -155,12 +161,15 @@ import {
|
|
|
155
161
|
useSharedSafeId,
|
|
156
162
|
useUniqueSafeId
|
|
157
163
|
} from "./lib/hooks/useSafeId.mjs";
|
|
164
|
+
import { useTransform } from "./lib/hooks/useTransform.mjs";
|
|
165
|
+
import { isCursorInViewport } from "./lib/utils/collaborators.mjs";
|
|
158
166
|
import { useTLSchemaFromUtils, useTLStore } from "./lib/hooks/useTLStore.mjs";
|
|
159
167
|
import { useViewportHeight } from "./lib/hooks/useViewportHeight.mjs";
|
|
160
168
|
import {
|
|
161
169
|
LicenseManager
|
|
162
170
|
} from "./lib/license/LicenseManager.mjs";
|
|
163
|
-
import { LICENSE_TIMEOUT } from "./lib/license/LicenseProvider.mjs";
|
|
171
|
+
import { LICENSE_TIMEOUT, useLicenseContext } from "./lib/license/LicenseProvider.mjs";
|
|
172
|
+
import { useLicenseFeatureFlag } from "./lib/license/useLicenseManagerState.mjs";
|
|
164
173
|
import {
|
|
165
174
|
defaultTldrawOptions
|
|
166
175
|
} from "./lib/options.mjs";
|
|
@@ -296,7 +305,7 @@ import { LocalIndexedDb, Table } from "./lib/utils/sync/LocalIndexedDb.mjs";
|
|
|
296
305
|
import { uniq } from "./lib/utils/uniq.mjs";
|
|
297
306
|
registerTldrawLibraryVersion(
|
|
298
307
|
"@tldraw/editor",
|
|
299
|
-
"5.3.0-canary.
|
|
308
|
+
"5.3.0-canary.dee64fee16b5",
|
|
300
309
|
"esm"
|
|
301
310
|
);
|
|
302
311
|
import { getColorValue } from "./lib/editor/managers/ThemeManager/defaultThemes.mjs";
|
|
@@ -320,6 +329,7 @@ export {
|
|
|
320
329
|
DEFAULT_THEME,
|
|
321
330
|
DefaultBackground,
|
|
322
331
|
DefaultCanvas,
|
|
332
|
+
DefaultCursor,
|
|
323
333
|
DefaultErrorFallback,
|
|
324
334
|
DefaultGrid,
|
|
325
335
|
DefaultShapeWrapper,
|
|
@@ -333,6 +343,7 @@ export {
|
|
|
333
343
|
EditorAtom,
|
|
334
344
|
EditorContext,
|
|
335
345
|
EditorManager,
|
|
346
|
+
EditorPortal,
|
|
336
347
|
EditorProvider,
|
|
337
348
|
Ellipse2d,
|
|
338
349
|
ErrorBoundary,
|
|
@@ -453,6 +464,7 @@ export {
|
|
|
453
464
|
intersectPolygonBounds,
|
|
454
465
|
intersectPolygonPolygon,
|
|
455
466
|
isAccelKey,
|
|
467
|
+
isCursorInViewport,
|
|
456
468
|
isSafeFloat,
|
|
457
469
|
kickoutOccludedShapes,
|
|
458
470
|
linesIntersect,
|
|
@@ -503,14 +515,16 @@ export {
|
|
|
503
515
|
useDelaySvgExport,
|
|
504
516
|
useEditor,
|
|
505
517
|
useEditorComponents,
|
|
518
|
+
useEditorPortalHost,
|
|
506
519
|
useEvent,
|
|
507
520
|
useGlobalMenuIsOpen,
|
|
508
521
|
useIsCropping,
|
|
509
522
|
useIsEditing,
|
|
523
|
+
useLicenseContext,
|
|
524
|
+
useLicenseFeatureFlag,
|
|
510
525
|
useLocalStore,
|
|
511
526
|
useMaybeEditor,
|
|
512
527
|
useOnMount,
|
|
513
|
-
usePassThroughMouseOverEvents,
|
|
514
528
|
usePassThroughWheelEvents,
|
|
515
529
|
usePeerIds,
|
|
516
530
|
usePresence,
|
|
@@ -523,6 +537,7 @@ export {
|
|
|
523
537
|
useTLSchemaFromUtils,
|
|
524
538
|
useTLStore,
|
|
525
539
|
useTldrawCurrentUser,
|
|
540
|
+
useTransform,
|
|
526
541
|
useUniqueSafeId,
|
|
527
542
|
useViewportHeight,
|
|
528
543
|
userTypeValidator
|