@tldraw/editor 3.16.0-internal.51e99e128bd4 → 3.16.0-internal.a478398270c6
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 +16 -217
- package/dist-cjs/index.js +1 -8
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +1 -3
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/MenuClickCapture.js +5 -0
- package/dist-cjs/lib/components/MenuClickCapture.js.map +2 -2
- package/dist-cjs/lib/components/SVGContainer.js +1 -1
- package/dist-cjs/lib/components/SVGContainer.js.map +2 -2
- package/dist-cjs/lib/components/Shape.js +26 -4
- package/dist-cjs/lib/components/Shape.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultBrush.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultBrush.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCursor.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCursor.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultGrid.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultGrid.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultHandles.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultHandles.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultScribble.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultScribble.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +1 -9
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js +15 -27
- package/dist-cjs/lib/components/default-components/DefaultSpinner.js.map +3 -3
- package/dist-cjs/lib/config/TLUserPreferences.js +3 -15
- package/dist-cjs/lib/config/TLUserPreferences.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +67 -134
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +4 -14
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/tools/StateNode.js +1 -20
- package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
- package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
- package/dist-cjs/lib/exports/getSvgJsx.js +2 -1
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +20 -24
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditor.js +4 -1
- package/dist-cjs/lib/hooks/useEditor.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js +0 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
- package/dist-cjs/lib/license/Watermark.js +8 -8
- package/dist-cjs/lib/license/Watermark.js.map +2 -2
- package/dist-cjs/lib/options.js +0 -7
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Arc2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Arc2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Circle2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Circle2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/CubicBezier2d.js +1 -3
- package/dist-cjs/lib/primitives/geometry/CubicBezier2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/geometry-constants.js +2 -2
- package/dist-cjs/lib/primitives/geometry/geometry-constants.js.map +2 -2
- package/dist-cjs/lib/primitives/intersect.js +4 -4
- package/dist-cjs/lib/primitives/intersect.js.map +2 -2
- package/dist-cjs/lib/primitives/utils.js +0 -4
- package/dist-cjs/lib/primitives/utils.js.map +2 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +1 -0
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +16 -217
- package/dist-esm/index.mjs +2 -16
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +1 -3
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/MenuClickCapture.mjs +5 -0
- package/dist-esm/lib/components/MenuClickCapture.mjs.map +2 -2
- package/dist-esm/lib/components/SVGContainer.mjs +1 -1
- package/dist-esm/lib/components/SVGContainer.mjs.map +2 -2
- package/dist-esm/lib/components/Shape.mjs +26 -4
- package/dist-esm/lib/components/Shape.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultBrush.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultBrush.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs +2 -2
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCursor.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCursor.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultGrid.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultGrid.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultHandles.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultHandles.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultScribble.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultScribble.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +1 -9
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs +15 -17
- package/dist-esm/lib/components/default-components/DefaultSpinner.mjs.map +2 -2
- package/dist-esm/lib/config/TLUserPreferences.mjs +3 -15
- package/dist-esm/lib/config/TLUserPreferences.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +67 -134
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +4 -14
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/StateNode.mjs +1 -20
- package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +21 -25
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditor.mjs +4 -1
- package/dist-esm/lib/hooks/useEditor.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs +0 -4
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
- package/dist-esm/lib/license/Watermark.mjs +8 -8
- package/dist-esm/lib/license/Watermark.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +0 -7
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Arc2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Arc2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Circle2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs +1 -3
- package/dist-esm/lib/primitives/geometry/CubicBezier2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/geometry-constants.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/geometry-constants.mjs.map +2 -2
- package/dist-esm/lib/primitives/intersect.mjs +5 -5
- package/dist-esm/lib/primitives/intersect.mjs.map +2 -2
- package/dist-esm/lib/primitives/utils.mjs +0 -4
- package/dist-esm/lib/primitives/utils.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +1 -0
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +313 -312
- package/package.json +38 -16
- package/src/index.ts +1 -15
- package/src/lib/TldrawEditor.tsx +5 -7
- package/src/lib/components/MenuClickCapture.tsx +8 -0
- package/src/lib/components/SVGContainer.tsx +1 -1
- package/src/lib/components/Shape.tsx +21 -6
- package/src/lib/components/default-components/DefaultBrush.tsx +1 -1
- package/src/lib/components/default-components/DefaultCanvas.tsx +1 -1
- package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +2 -2
- package/src/lib/components/default-components/DefaultCursor.tsx +1 -1
- package/src/lib/components/default-components/DefaultErrorFallback.tsx +1 -1
- package/src/lib/components/default-components/DefaultGrid.tsx +1 -1
- package/src/lib/components/default-components/DefaultHandles.tsx +1 -5
- package/src/lib/components/default-components/DefaultScribble.tsx +1 -1
- package/src/lib/components/default-components/DefaultShapeIndicator.tsx +2 -6
- package/src/lib/components/default-components/DefaultSnapIndictor.tsx +1 -1
- package/src/lib/components/default-components/DefaultSpinner.tsx +12 -12
- package/src/lib/config/TLUserPreferences.ts +1 -15
- package/src/lib/editor/Editor.test.ts +8 -416
- package/src/lib/editor/Editor.ts +92 -177
- package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +14 -15
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.test.ts +15 -16
- package/src/lib/editor/managers/FocusManager/FocusManager.test.ts +48 -49
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +23 -24
- package/src/lib/editor/managers/HistoryManager/HistoryManager.test.ts +6 -7
- package/src/lib/editor/managers/ScribbleManager/ScribbleManager.test.ts +11 -12
- package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +50 -57
- package/src/lib/editor/managers/TextManager/TextManager.test.ts +26 -51
- package/src/lib/editor/managers/TickManager/TickManager.test.ts +13 -14
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +26 -55
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +1 -14
- package/src/lib/editor/shapes/ShapeUtil.ts +0 -57
- package/src/lib/editor/tools/StateNode.ts +1 -27
- package/src/lib/editor/types/misc-types.ts +1 -73
- package/src/lib/exports/getSvgJsx.tsx +2 -2
- package/src/lib/hooks/useCanvasEvents.ts +32 -39
- package/src/lib/hooks/useEditor.tsx +5 -6
- package/src/lib/hooks/useEditorComponents.tsx +2 -8
- package/src/lib/license/LicenseManager.test.ts +1 -3
- package/src/lib/license/Watermark.test.tsx +1 -2
- package/src/lib/license/Watermark.tsx +8 -8
- package/src/lib/options.ts +0 -8
- package/src/lib/primitives/geometry/Arc2d.ts +2 -2
- package/src/lib/primitives/geometry/Circle2d.ts +2 -2
- package/src/lib/primitives/geometry/CubicBezier2d.ts +1 -4
- package/src/lib/primitives/geometry/Ellipse2d.ts +2 -2
- package/src/lib/primitives/geometry/geometry-constants.ts +1 -2
- package/src/lib/primitives/intersect.ts +5 -12
- package/src/lib/primitives/utils.ts +0 -11
- package/src/lib/test/currentToolIdMask.test.ts +49 -0
- package/src/lib/utils/sync/LocalIndexedDb.test.ts +1 -2
- package/src/lib/utils/sync/TLLocalSyncClient.test.ts +15 -15
- package/src/lib/utils/sync/TLLocalSyncClient.ts +1 -0
- package/src/version.ts +3 -3
- package/dist-cjs/lib/components/default-components/DefaultShapeWrapper.js +0 -53
- package/dist-cjs/lib/components/default-components/DefaultShapeWrapper.js.map +0 -7
- package/dist-cjs/lib/hooks/useStateAttribute.js +0 -35
- package/dist-cjs/lib/hooks/useStateAttribute.js.map +0 -7
- package/dist-cjs/lib/utils/EditorAtom.js +0 -45
- package/dist-cjs/lib/utils/EditorAtom.js.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultShapeWrapper.mjs +0 -23
- package/dist-esm/lib/components/default-components/DefaultShapeWrapper.mjs.map +0 -7
- package/dist-esm/lib/hooks/useStateAttribute.mjs +0 -15
- package/dist-esm/lib/hooks/useStateAttribute.mjs.map +0 -7
- package/dist-esm/lib/utils/EditorAtom.mjs +0 -25
- package/dist-esm/lib/utils/EditorAtom.mjs.map +0 -7
- package/src/lib/components/default-components/DefaultShapeWrapper.tsx +0 -35
- package/src/lib/editor/tools/StateNode.test.ts +0 -285
- package/src/lib/hooks/useStateAttribute.ts +0 -15
- package/src/lib/primitives/intersect.test.ts +0 -946
- package/src/lib/utils/EditorAtom.ts +0 -37
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PageRecordType } from '@tldraw/tlschema'
|
|
2
2
|
import { IndexKey, promiseWithResolve } from '@tldraw/utils'
|
|
3
|
-
import {
|
|
3
|
+
import { afterEach } from 'node:test'
|
|
4
4
|
import { createTLStore } from '../../config/createTLStore'
|
|
5
5
|
import { TLLocalSyncClient } from './TLLocalSyncClient'
|
|
6
6
|
import { hardReset } from './hardReset'
|
|
@@ -10,20 +10,20 @@ class BroadcastChannelMock {
|
|
|
10
10
|
constructor(_name: string) {
|
|
11
11
|
// noop
|
|
12
12
|
}
|
|
13
|
-
postMessage =
|
|
13
|
+
postMessage = jest.fn((_msg: any) => {
|
|
14
14
|
// noop
|
|
15
15
|
})
|
|
16
|
-
close =
|
|
16
|
+
close = jest.fn(() => {
|
|
17
17
|
// noop
|
|
18
18
|
})
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function testClient(channel = new BroadcastChannelMock('test')) {
|
|
22
22
|
const store = createTLStore({ shapeUtils: [], bindingUtils: [] })
|
|
23
|
-
const onLoad =
|
|
23
|
+
const onLoad = jest.fn(() => {
|
|
24
24
|
return
|
|
25
25
|
})
|
|
26
|
-
const onLoadError =
|
|
26
|
+
const onLoadError = jest.fn(() => {
|
|
27
27
|
return
|
|
28
28
|
})
|
|
29
29
|
const client = new TLLocalSyncClient(
|
|
@@ -36,26 +36,26 @@ function testClient(channel = new BroadcastChannelMock('test')) {
|
|
|
36
36
|
channel
|
|
37
37
|
)
|
|
38
38
|
|
|
39
|
-
client.db.storeSnapshot =
|
|
40
|
-
client.db.storeChanges =
|
|
39
|
+
client.db.storeSnapshot = jest.fn(() => Promise.resolve())
|
|
40
|
+
client.db.storeChanges = jest.fn(() => Promise.resolve())
|
|
41
41
|
|
|
42
42
|
return {
|
|
43
|
-
client: client as { db: { storeSnapshot: Mock; storeChanges: Mock } } & typeof client,
|
|
43
|
+
client: client as { db: { storeSnapshot: jest.Mock; storeChanges: jest.Mock } } & typeof client,
|
|
44
44
|
store,
|
|
45
45
|
onLoad,
|
|
46
46
|
onLoadError,
|
|
47
47
|
channel,
|
|
48
48
|
tick: async () => {
|
|
49
|
-
|
|
49
|
+
jest.advanceTimersByTime(500)
|
|
50
50
|
await Promise.resolve()
|
|
51
51
|
await client.db.pending()
|
|
52
|
-
|
|
52
|
+
jest.advanceTimersByTime(500)
|
|
53
53
|
await Promise.resolve()
|
|
54
54
|
},
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
const reloadMock =
|
|
58
|
+
const reloadMock = jest.fn()
|
|
59
59
|
|
|
60
60
|
beforeAll(() => {
|
|
61
61
|
Object.defineProperty(window, 'location', {
|
|
@@ -65,14 +65,14 @@ beforeAll(() => {
|
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
beforeEach(() => {
|
|
68
|
-
|
|
68
|
+
jest.clearAllMocks()
|
|
69
69
|
})
|
|
70
70
|
|
|
71
71
|
afterEach(async () => {
|
|
72
72
|
await hardReset({ shouldReload: false })
|
|
73
73
|
})
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
jest.useFakeTimers()
|
|
76
76
|
|
|
77
77
|
test('the client connects on instantiation, announcing its schema', async () => {
|
|
78
78
|
const { channel, tick } = testClient()
|
|
@@ -86,7 +86,7 @@ test('the client connects on instantiation, announcing its schema', async () =>
|
|
|
86
86
|
test('when a client receives an announce with a newer schema version it reloads itself', async () => {
|
|
87
87
|
const { client, channel, onLoadError, tick } = testClient()
|
|
88
88
|
await tick()
|
|
89
|
-
|
|
89
|
+
jest.advanceTimersByTime(10000)
|
|
90
90
|
expect(reloadMock).not.toHaveBeenCalled()
|
|
91
91
|
channel.onmessage?.({
|
|
92
92
|
data: {
|
|
@@ -104,7 +104,7 @@ test('when a client receives an announce with a newer schema version it reloads
|
|
|
104
104
|
test('when a client receives an announce with a newer schema version shortly after loading it does not reload but instead reports a loadError', async () => {
|
|
105
105
|
const { client, channel, onLoadError, tick } = testClient()
|
|
106
106
|
await tick()
|
|
107
|
-
|
|
107
|
+
jest.advanceTimersByTime(1000)
|
|
108
108
|
expect(reloadMock).not.toHaveBeenCalled()
|
|
109
109
|
channel.onmessage?.({
|
|
110
110
|
data: {
|
|
@@ -266,6 +266,7 @@ export class TLLocalSyncClient {
|
|
|
266
266
|
|
|
267
267
|
private isPersisting = false
|
|
268
268
|
private didLastWriteError = false
|
|
269
|
+
// eslint-disable-next-line no-restricted-globals
|
|
269
270
|
private scheduledPersistTimeout: ReturnType<typeof setTimeout> | null = null
|
|
270
271
|
|
|
271
272
|
/**
|
package/src/version.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// This file is automatically generated by internal/scripts/refresh-assets.ts.
|
|
2
2
|
// Do not edit manually. Or do, I'm a comment, not a cop.
|
|
3
3
|
|
|
4
|
-
export const version = '3.16.0-internal.
|
|
4
|
+
export const version = '3.16.0-internal.a478398270c6'
|
|
5
5
|
export const publishDates = {
|
|
6
6
|
major: '2024-09-13T14:36:29.063Z',
|
|
7
|
-
minor: '2025-08-19T10:
|
|
8
|
-
patch: '2025-08-19T10:
|
|
7
|
+
minor: '2025-08-19T10:21:26.717Z',
|
|
8
|
+
patch: '2025-08-19T10:21:26.717Z',
|
|
9
9
|
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var DefaultShapeWrapper_exports = {};
|
|
30
|
-
__export(DefaultShapeWrapper_exports, {
|
|
31
|
-
DefaultShapeWrapper: () => DefaultShapeWrapper
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(DefaultShapeWrapper_exports);
|
|
34
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
-
var import_classnames = __toESM(require("classnames"));
|
|
36
|
-
var import_react = require("react");
|
|
37
|
-
const DefaultShapeWrapper = (0, import_react.forwardRef)(function DefaultShapeWrapper2({ children, shape, isBackground, ...props }, ref) {
|
|
38
|
-
const isFilledShape = "fill" in shape.props && shape.props.fill !== "none";
|
|
39
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
40
|
-
"div",
|
|
41
|
-
{
|
|
42
|
-
ref,
|
|
43
|
-
"data-shape-type": shape.type,
|
|
44
|
-
"data-shape-is-filled": isBackground ? void 0 : isFilledShape,
|
|
45
|
-
"data-shape-id": shape.id,
|
|
46
|
-
draggable: false,
|
|
47
|
-
...props,
|
|
48
|
-
className: (0, import_classnames.default)("tl-shape", isBackground && "tl-shape-background", props.className),
|
|
49
|
-
children
|
|
50
|
-
}
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
//# sourceMappingURL=DefaultShapeWrapper.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/lib/components/default-components/DefaultShapeWrapper.tsx"],
|
|
4
|
-
"sourcesContent": ["import { TLShape } from '@tldraw/tlschema'\nimport classNames from 'classnames'\nimport { forwardRef, ReactNode } from 'react'\n\n/** @public */\nexport interface TLShapeWrapperProps extends React.HTMLAttributes<HTMLDivElement> {\n\t/** The shape being rendered. */\n\tshape: TLShape\n\t/** Whether this is the shapes regular, or background component. */\n\tisBackground: boolean\n\t/** The shape's rendered component. */\n\tchildren: ReactNode\n}\n\n/** @public @react */\nexport const DefaultShapeWrapper = forwardRef(function DefaultShapeWrapper(\n\t{ children, shape, isBackground, ...props }: TLShapeWrapperProps,\n\tref: React.Ref<HTMLDivElement>\n) {\n\tconst isFilledShape = 'fill' in shape.props && shape.props.fill !== 'none'\n\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tdata-shape-type={shape.type}\n\t\t\tdata-shape-is-filled={isBackground ? undefined : isFilledShape}\n\t\t\tdata-shape-id={shape.id}\n\t\t\tdraggable={false}\n\t\t\t{...props}\n\t\t\tclassName={classNames('tl-shape', isBackground && 'tl-shape-background', props.className)}\n\t\t>\n\t\t\t{children}\n\t\t</div>\n\t)\n})\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBE;AArBF,wBAAuB;AACvB,mBAAsC;AAa/B,MAAM,0BAAsB,yBAAW,SAASA,qBACtD,EAAE,UAAU,OAAO,cAAc,GAAG,MAAM,GAC1C,KACC;AACD,QAAM,gBAAgB,UAAU,MAAM,SAAS,MAAM,MAAM,SAAS;AAEpE,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,mBAAiB,MAAM;AAAA,MACvB,wBAAsB,eAAe,SAAY;AAAA,MACjD,iBAAe,MAAM;AAAA,MACrB,WAAW;AAAA,MACV,GAAG;AAAA,MACJ,eAAW,kBAAAC,SAAW,YAAY,gBAAgB,uBAAuB,MAAM,SAAS;AAAA,MAEvF;AAAA;AAAA,EACF;AAEF,CAAC;",
|
|
6
|
-
"names": ["DefaultShapeWrapper", "classNames"]
|
|
7
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
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 useStateAttribute_exports = {};
|
|
20
|
-
__export(useStateAttribute_exports, {
|
|
21
|
-
useStateAttribute: () => useStateAttribute
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(useStateAttribute_exports);
|
|
24
|
-
var import_state = require("@tldraw/state");
|
|
25
|
-
var import_react = require("react");
|
|
26
|
-
var import_useEditor = require("./useEditor");
|
|
27
|
-
function useStateAttribute() {
|
|
28
|
-
const editor = (0, import_useEditor.useEditor)();
|
|
29
|
-
(0, import_react.useLayoutEffect)(() => {
|
|
30
|
-
return (0, import_state.react)("stateAttribute", () => {
|
|
31
|
-
editor.getContainer().setAttribute("data-state", editor.getPath());
|
|
32
|
-
});
|
|
33
|
-
}, [editor]);
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=useStateAttribute.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/lib/hooks/useStateAttribute.ts"],
|
|
4
|
-
"sourcesContent": ["import { react } from '@tldraw/state'\nimport { useLayoutEffect } from 'react'\nimport { useEditor } from './useEditor'\n\nexport function useStateAttribute() {\n\tconst editor = useEditor()\n\n\t// we use a layout effect because we don't want there to be any perceptible delay between the\n\t// editor mounting and this attribute being applied, because styles may depend on it:\n\tuseLayoutEffect(() => {\n\t\treturn react('stateAttribute', () => {\n\t\t\teditor.getContainer().setAttribute('data-state', editor.getPath())\n\t\t})\n\t}, [editor])\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AACtB,mBAAgC;AAChC,uBAA0B;AAEnB,SAAS,oBAAoB;AACnC,QAAM,aAAS,4BAAU;AAIzB,oCAAgB,MAAM;AACrB,eAAO,oBAAM,kBAAkB,MAAM;AACpC,aAAO,aAAa,EAAE,aAAa,cAAc,OAAO,QAAQ,CAAC;AAAA,IAClE,CAAC;AAAA,EACF,GAAG,CAAC,MAAM,CAAC;AACZ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
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 EditorAtom_exports = {};
|
|
20
|
-
__export(EditorAtom_exports, {
|
|
21
|
-
EditorAtom: () => EditorAtom
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(EditorAtom_exports);
|
|
24
|
-
var import_state = require("@tldraw/state");
|
|
25
|
-
var import_utils = require("@tldraw/utils");
|
|
26
|
-
class EditorAtom {
|
|
27
|
-
constructor(name, getInitialState) {
|
|
28
|
-
this.name = name;
|
|
29
|
-
this.getInitialState = getInitialState;
|
|
30
|
-
}
|
|
31
|
-
states = new import_utils.WeakCache();
|
|
32
|
-
getAtom(editor) {
|
|
33
|
-
return this.states.get(editor, () => (0, import_state.atom)(this.name, this.getInitialState(editor)));
|
|
34
|
-
}
|
|
35
|
-
get(editor) {
|
|
36
|
-
return this.getAtom(editor).get();
|
|
37
|
-
}
|
|
38
|
-
update(editor, update) {
|
|
39
|
-
return this.getAtom(editor).update(update);
|
|
40
|
-
}
|
|
41
|
-
set(editor, state) {
|
|
42
|
-
return this.getAtom(editor).set(state);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=EditorAtom.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/lib/utils/EditorAtom.ts"],
|
|
4
|
-
"sourcesContent": ["import { atom, Atom } from '@tldraw/state'\nimport { WeakCache } from '@tldraw/utils'\nimport { Editor } from '../editor/Editor'\n\n/**\n * An Atom that is scoped to the lifetime of an Editor.\n *\n * This is useful for storing UI state for tldraw applications. Keeping state scoped to an editor\n * instead of stored in a global atom can prevent issues with state being shared between editors\n * when navigating between pages, or when multiple editor instances are used on the same page.\n *\n * @public\n */\nexport class EditorAtom<T> {\n\tprivate states = new WeakCache<Editor, Atom<T>>()\n\n\tconstructor(\n\t\tprivate name: string,\n\t\tprivate getInitialState: (editor: Editor) => T\n\t) {}\n\n\tgetAtom(editor: Editor): Atom<T> {\n\t\treturn this.states.get(editor, () => atom(this.name, this.getInitialState(editor)))\n\t}\n\n\tget(editor: Editor): T {\n\t\treturn this.getAtom(editor).get()\n\t}\n\n\tupdate(editor: Editor, update: (state: T) => T): T {\n\t\treturn this.getAtom(editor).update(update)\n\t}\n\n\tset(editor: Editor, state: T): T {\n\t\treturn this.getAtom(editor).set(state)\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAC3B,mBAA0B;AAYnB,MAAM,WAAc;AAAA,EAG1B,YACS,MACA,iBACP;AAFO;AACA;AAAA,EACN;AAAA,EALK,SAAS,IAAI,uBAA2B;AAAA,EAOhD,QAAQ,QAAyB;AAChC,WAAO,KAAK,OAAO,IAAI,QAAQ,UAAM,mBAAK,KAAK,MAAM,KAAK,gBAAgB,MAAM,CAAC,CAAC;AAAA,EACnF;AAAA,EAEA,IAAI,QAAmB;AACtB,WAAO,KAAK,QAAQ,MAAM,EAAE,IAAI;AAAA,EACjC;AAAA,EAEA,OAAO,QAAgB,QAA4B;AAClD,WAAO,KAAK,QAAQ,MAAM,EAAE,OAAO,MAAM;AAAA,EAC1C;AAAA,EAEA,IAAI,QAAgB,OAAa;AAChC,WAAO,KAAK,QAAQ,MAAM,EAAE,IAAI,KAAK;AAAA,EACtC;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import classNames from "classnames";
|
|
3
|
-
import { forwardRef } from "react";
|
|
4
|
-
const DefaultShapeWrapper = forwardRef(function DefaultShapeWrapper2({ children, shape, isBackground, ...props }, ref) {
|
|
5
|
-
const isFilledShape = "fill" in shape.props && shape.props.fill !== "none";
|
|
6
|
-
return /* @__PURE__ */ jsx(
|
|
7
|
-
"div",
|
|
8
|
-
{
|
|
9
|
-
ref,
|
|
10
|
-
"data-shape-type": shape.type,
|
|
11
|
-
"data-shape-is-filled": isBackground ? void 0 : isFilledShape,
|
|
12
|
-
"data-shape-id": shape.id,
|
|
13
|
-
draggable: false,
|
|
14
|
-
...props,
|
|
15
|
-
className: classNames("tl-shape", isBackground && "tl-shape-background", props.className),
|
|
16
|
-
children
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
export {
|
|
21
|
-
DefaultShapeWrapper
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=DefaultShapeWrapper.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/lib/components/default-components/DefaultShapeWrapper.tsx"],
|
|
4
|
-
"sourcesContent": ["import { TLShape } from '@tldraw/tlschema'\nimport classNames from 'classnames'\nimport { forwardRef, ReactNode } from 'react'\n\n/** @public */\nexport interface TLShapeWrapperProps extends React.HTMLAttributes<HTMLDivElement> {\n\t/** The shape being rendered. */\n\tshape: TLShape\n\t/** Whether this is the shapes regular, or background component. */\n\tisBackground: boolean\n\t/** The shape's rendered component. */\n\tchildren: ReactNode\n}\n\n/** @public @react */\nexport const DefaultShapeWrapper = forwardRef(function DefaultShapeWrapper(\n\t{ children, shape, isBackground, ...props }: TLShapeWrapperProps,\n\tref: React.Ref<HTMLDivElement>\n) {\n\tconst isFilledShape = 'fill' in shape.props && shape.props.fill !== 'none'\n\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tdata-shape-type={shape.type}\n\t\t\tdata-shape-is-filled={isBackground ? undefined : isFilledShape}\n\t\t\tdata-shape-id={shape.id}\n\t\t\tdraggable={false}\n\t\t\t{...props}\n\t\t\tclassName={classNames('tl-shape', isBackground && 'tl-shape-background', props.className)}\n\t\t>\n\t\t\t{children}\n\t\t</div>\n\t)\n})\n"],
|
|
5
|
-
"mappings": "AAsBE;AArBF,OAAO,gBAAgB;AACvB,SAAS,kBAA6B;AAa/B,MAAM,sBAAsB,WAAW,SAASA,qBACtD,EAAE,UAAU,OAAO,cAAc,GAAG,MAAM,GAC1C,KACC;AACD,QAAM,gBAAgB,UAAU,MAAM,SAAS,MAAM,MAAM,SAAS;AAEpE,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,mBAAiB,MAAM;AAAA,MACvB,wBAAsB,eAAe,SAAY;AAAA,MACjD,iBAAe,MAAM;AAAA,MACrB,WAAW;AAAA,MACV,GAAG;AAAA,MACJ,WAAW,WAAW,YAAY,gBAAgB,uBAAuB,MAAM,SAAS;AAAA,MAEvF;AAAA;AAAA,EACF;AAEF,CAAC;",
|
|
6
|
-
"names": ["DefaultShapeWrapper"]
|
|
7
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { react } from "@tldraw/state";
|
|
2
|
-
import { useLayoutEffect } from "react";
|
|
3
|
-
import { useEditor } from "./useEditor.mjs";
|
|
4
|
-
function useStateAttribute() {
|
|
5
|
-
const editor = useEditor();
|
|
6
|
-
useLayoutEffect(() => {
|
|
7
|
-
return react("stateAttribute", () => {
|
|
8
|
-
editor.getContainer().setAttribute("data-state", editor.getPath());
|
|
9
|
-
});
|
|
10
|
-
}, [editor]);
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
useStateAttribute
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=useStateAttribute.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/lib/hooks/useStateAttribute.ts"],
|
|
4
|
-
"sourcesContent": ["import { react } from '@tldraw/state'\nimport { useLayoutEffect } from 'react'\nimport { useEditor } from './useEditor'\n\nexport function useStateAttribute() {\n\tconst editor = useEditor()\n\n\t// we use a layout effect because we don't want there to be any perceptible delay between the\n\t// editor mounting and this attribute being applied, because styles may depend on it:\n\tuseLayoutEffect(() => {\n\t\treturn react('stateAttribute', () => {\n\t\t\teditor.getContainer().setAttribute('data-state', editor.getPath())\n\t\t})\n\t}, [editor])\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,aAAa;AACtB,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAEnB,SAAS,oBAAoB;AACnC,QAAM,SAAS,UAAU;AAIzB,kBAAgB,MAAM;AACrB,WAAO,MAAM,kBAAkB,MAAM;AACpC,aAAO,aAAa,EAAE,aAAa,cAAc,OAAO,QAAQ,CAAC;AAAA,IAClE,CAAC;AAAA,EACF,GAAG,CAAC,MAAM,CAAC;AACZ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { atom } from "@tldraw/state";
|
|
2
|
-
import { WeakCache } from "@tldraw/utils";
|
|
3
|
-
class EditorAtom {
|
|
4
|
-
constructor(name, getInitialState) {
|
|
5
|
-
this.name = name;
|
|
6
|
-
this.getInitialState = getInitialState;
|
|
7
|
-
}
|
|
8
|
-
states = new WeakCache();
|
|
9
|
-
getAtom(editor) {
|
|
10
|
-
return this.states.get(editor, () => atom(this.name, this.getInitialState(editor)));
|
|
11
|
-
}
|
|
12
|
-
get(editor) {
|
|
13
|
-
return this.getAtom(editor).get();
|
|
14
|
-
}
|
|
15
|
-
update(editor, update) {
|
|
16
|
-
return this.getAtom(editor).update(update);
|
|
17
|
-
}
|
|
18
|
-
set(editor, state) {
|
|
19
|
-
return this.getAtom(editor).set(state);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
EditorAtom
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=EditorAtom.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/lib/utils/EditorAtom.ts"],
|
|
4
|
-
"sourcesContent": ["import { atom, Atom } from '@tldraw/state'\nimport { WeakCache } from '@tldraw/utils'\nimport { Editor } from '../editor/Editor'\n\n/**\n * An Atom that is scoped to the lifetime of an Editor.\n *\n * This is useful for storing UI state for tldraw applications. Keeping state scoped to an editor\n * instead of stored in a global atom can prevent issues with state being shared between editors\n * when navigating between pages, or when multiple editor instances are used on the same page.\n *\n * @public\n */\nexport class EditorAtom<T> {\n\tprivate states = new WeakCache<Editor, Atom<T>>()\n\n\tconstructor(\n\t\tprivate name: string,\n\t\tprivate getInitialState: (editor: Editor) => T\n\t) {}\n\n\tgetAtom(editor: Editor): Atom<T> {\n\t\treturn this.states.get(editor, () => atom(this.name, this.getInitialState(editor)))\n\t}\n\n\tget(editor: Editor): T {\n\t\treturn this.getAtom(editor).get()\n\t}\n\n\tupdate(editor: Editor, update: (state: T) => T): T {\n\t\treturn this.getAtom(editor).update(update)\n\t}\n\n\tset(editor: Editor, state: T): T {\n\t\treturn this.getAtom(editor).set(state)\n\t}\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,YAAkB;AAC3B,SAAS,iBAAiB;AAYnB,MAAM,WAAc;AAAA,EAG1B,YACS,MACA,iBACP;AAFO;AACA;AAAA,EACN;AAAA,EALK,SAAS,IAAI,UAA2B;AAAA,EAOhD,QAAQ,QAAyB;AAChC,WAAO,KAAK,OAAO,IAAI,QAAQ,MAAM,KAAK,KAAK,MAAM,KAAK,gBAAgB,MAAM,CAAC,CAAC;AAAA,EACnF;AAAA,EAEA,IAAI,QAAmB;AACtB,WAAO,KAAK,QAAQ,MAAM,EAAE,IAAI;AAAA,EACjC;AAAA,EAEA,OAAO,QAAgB,QAA4B;AAClD,WAAO,KAAK,QAAQ,MAAM,EAAE,OAAO,MAAM;AAAA,EAC1C;AAAA,EAEA,IAAI,QAAgB,OAAa;AAChC,WAAO,KAAK,QAAQ,MAAM,EAAE,IAAI,KAAK;AAAA,EACtC;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { TLShape } from '@tldraw/tlschema'
|
|
2
|
-
import classNames from 'classnames'
|
|
3
|
-
import { forwardRef, ReactNode } from 'react'
|
|
4
|
-
|
|
5
|
-
/** @public */
|
|
6
|
-
export interface TLShapeWrapperProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
7
|
-
/** The shape being rendered. */
|
|
8
|
-
shape: TLShape
|
|
9
|
-
/** Whether this is the shapes regular, or background component. */
|
|
10
|
-
isBackground: boolean
|
|
11
|
-
/** The shape's rendered component. */
|
|
12
|
-
children: ReactNode
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/** @public @react */
|
|
16
|
-
export const DefaultShapeWrapper = forwardRef(function DefaultShapeWrapper(
|
|
17
|
-
{ children, shape, isBackground, ...props }: TLShapeWrapperProps,
|
|
18
|
-
ref: React.Ref<HTMLDivElement>
|
|
19
|
-
) {
|
|
20
|
-
const isFilledShape = 'fill' in shape.props && shape.props.fill !== 'none'
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div
|
|
24
|
-
ref={ref}
|
|
25
|
-
data-shape-type={shape.type}
|
|
26
|
-
data-shape-is-filled={isBackground ? undefined : isFilledShape}
|
|
27
|
-
data-shape-id={shape.id}
|
|
28
|
-
draggable={false}
|
|
29
|
-
{...props}
|
|
30
|
-
className={classNames('tl-shape', isBackground && 'tl-shape-background', props.className)}
|
|
31
|
-
>
|
|
32
|
-
{children}
|
|
33
|
-
</div>
|
|
34
|
-
)
|
|
35
|
-
})
|