@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
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tldraw/editor",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "3.16.0-internal.
|
|
3
|
+
"description": "A tiny little drawing app (editor).",
|
|
4
|
+
"version": "3.16.0-internal.a478398270c6",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "tldraw Inc.",
|
|
7
7
|
"email": "hello@tldraw.com"
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
19
|
"tldraw",
|
|
20
|
-
"sdk",
|
|
21
20
|
"drawing",
|
|
22
21
|
"app",
|
|
23
22
|
"development",
|
|
@@ -34,28 +33,27 @@
|
|
|
34
33
|
"src"
|
|
35
34
|
],
|
|
36
35
|
"scripts": {
|
|
37
|
-
"test-ci": "
|
|
38
|
-
"test": "yarn run -T
|
|
36
|
+
"test-ci": "lazy inherit",
|
|
37
|
+
"test": "yarn run -T jest",
|
|
39
38
|
"benchmark": "yarn run -T tsx ./internal/scripts/benchmark.ts",
|
|
40
|
-
"test-coverage": "
|
|
39
|
+
"test-coverage": "lazy inherit",
|
|
41
40
|
"build": "yarn run -T tsx ../../internal/scripts/build-package.ts",
|
|
42
41
|
"build-api": "yarn run -T tsx ../../internal/scripts/build-api.ts",
|
|
43
42
|
"prepack": "yarn run -T tsx ../../internal/scripts/prepack.ts",
|
|
44
43
|
"postpack": "../../internal/scripts/postpack.sh",
|
|
45
44
|
"pack-tarball": "yarn pack",
|
|
46
|
-
"lint": "yarn run -T tsx ../../internal/scripts/lint.ts"
|
|
47
|
-
"context": "yarn run -T tsx ../../internal/scripts/context.ts"
|
|
45
|
+
"lint": "yarn run -T tsx ../../internal/scripts/lint.ts"
|
|
48
46
|
},
|
|
49
47
|
"dependencies": {
|
|
50
48
|
"@tiptap/core": "^2.9.1",
|
|
51
49
|
"@tiptap/pm": "^2.9.1",
|
|
52
50
|
"@tiptap/react": "^2.9.1",
|
|
53
|
-
"@tldraw/state": "3.16.0-internal.
|
|
54
|
-
"@tldraw/state-react": "3.16.0-internal.
|
|
55
|
-
"@tldraw/store": "3.16.0-internal.
|
|
56
|
-
"@tldraw/tlschema": "3.16.0-internal.
|
|
57
|
-
"@tldraw/utils": "3.16.0-internal.
|
|
58
|
-
"@tldraw/validate": "3.16.0-internal.
|
|
51
|
+
"@tldraw/state": "3.16.0-internal.a478398270c6",
|
|
52
|
+
"@tldraw/state-react": "3.16.0-internal.a478398270c6",
|
|
53
|
+
"@tldraw/store": "3.16.0-internal.a478398270c6",
|
|
54
|
+
"@tldraw/tlschema": "3.16.0-internal.a478398270c6",
|
|
55
|
+
"@tldraw/utils": "3.16.0-internal.a478398270c6",
|
|
56
|
+
"@tldraw/validate": "3.16.0-internal.a478398270c6",
|
|
59
57
|
"@types/core-js": "^2.5.8",
|
|
60
58
|
"@use-gesture/react": "^10.3.1",
|
|
61
59
|
"classnames": "^2.5.1",
|
|
@@ -70,17 +68,41 @@
|
|
|
70
68
|
},
|
|
71
69
|
"devDependencies": {
|
|
72
70
|
"@peculiar/webcrypto": "^1.5.0",
|
|
71
|
+
"@testing-library/jest-dom": "^5.17.0",
|
|
73
72
|
"@testing-library/react": "^15.0.7",
|
|
74
73
|
"@types/benchmark": "^2.1.5",
|
|
75
74
|
"@types/react": "^18.3.18",
|
|
76
75
|
"@types/wicg-file-system-access": "^2020.9.8",
|
|
77
76
|
"benchmark": "^2.1.4",
|
|
78
77
|
"fake-indexeddb": "^4.0.2",
|
|
78
|
+
"jest-canvas-mock": "^2.5.2",
|
|
79
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
79
80
|
"lazyrepo": "0.0.0-alpha.27",
|
|
80
81
|
"react": "^18.3.1",
|
|
81
82
|
"react-dom": "^18.3.1",
|
|
82
|
-
"resize-observer-polyfill": "^1.5.1"
|
|
83
|
-
|
|
83
|
+
"resize-observer-polyfill": "^1.5.1"
|
|
84
|
+
},
|
|
85
|
+
"jest": {
|
|
86
|
+
"preset": "../../internal/config/jest/node/jest-preset.js",
|
|
87
|
+
"testEnvironment": "../../../packages/utils/patchedJestJsDom.js",
|
|
88
|
+
"fakeTimers": {
|
|
89
|
+
"enableGlobally": true
|
|
90
|
+
},
|
|
91
|
+
"testPathIgnorePatterns": [
|
|
92
|
+
"^.+\\.*.css$"
|
|
93
|
+
],
|
|
94
|
+
"moduleNameMapper": {
|
|
95
|
+
"^~(.*)": "<rootDir>/src/$1",
|
|
96
|
+
"\\.(css|less|scss|sass)$": "identity-obj-proxy"
|
|
97
|
+
},
|
|
98
|
+
"setupFiles": [
|
|
99
|
+
"raf/polyfill",
|
|
100
|
+
"jest-canvas-mock",
|
|
101
|
+
"<rootDir>/setupTests.js"
|
|
102
|
+
],
|
|
103
|
+
"setupFilesAfterEnv": [
|
|
104
|
+
"../../internal/config/setupJest.ts"
|
|
105
|
+
]
|
|
84
106
|
},
|
|
85
107
|
"module": "dist-esm/index.mjs",
|
|
86
108
|
"source": "src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -67,10 +67,6 @@ export {
|
|
|
67
67
|
DefaultShapeIndicators,
|
|
68
68
|
type TLShapeIndicatorsProps,
|
|
69
69
|
} from './lib/components/default-components/DefaultShapeIndicators'
|
|
70
|
-
export {
|
|
71
|
-
DefaultShapeWrapper,
|
|
72
|
-
type TLShapeWrapperProps,
|
|
73
|
-
} from './lib/components/default-components/DefaultShapeWrapper'
|
|
74
70
|
export {
|
|
75
71
|
DefaultSnapIndicator,
|
|
76
72
|
type TLSnapIndicatorProps,
|
|
@@ -265,11 +261,9 @@ export {
|
|
|
265
261
|
type TLCameraMoveOptions,
|
|
266
262
|
type TLCameraOptions,
|
|
267
263
|
type TLExportType,
|
|
268
|
-
type TLGetShapeAtPointOptions,
|
|
269
264
|
type TLImageExportOptions,
|
|
270
265
|
type TLSvgExportOptions,
|
|
271
266
|
type TLSvgOptions,
|
|
272
|
-
type TLUpdatePointerOptions,
|
|
273
267
|
} from './lib/editor/types/misc-types'
|
|
274
268
|
export {
|
|
275
269
|
type TLAdjacentDirection,
|
|
@@ -293,13 +287,7 @@ export {
|
|
|
293
287
|
type ContainerProviderProps,
|
|
294
288
|
} from './lib/hooks/useContainer'
|
|
295
289
|
export { getCursor } from './lib/hooks/useCursor'
|
|
296
|
-
export {
|
|
297
|
-
EditorContext,
|
|
298
|
-
EditorProvider,
|
|
299
|
-
useEditor,
|
|
300
|
-
useMaybeEditor,
|
|
301
|
-
type EditorProviderProps,
|
|
302
|
-
} from './lib/hooks/useEditor'
|
|
290
|
+
export { EditorContext, useEditor, useMaybeEditor } from './lib/hooks/useEditor'
|
|
303
291
|
export { useEditorComponents } from './lib/hooks/useEditorComponents'
|
|
304
292
|
export type { TLEditorComponents } from './lib/hooks/useEditorComponents'
|
|
305
293
|
export { useEvent, useReactiveEvent } from './lib/hooks/useEvent'
|
|
@@ -352,7 +340,6 @@ export { CubicBezier2d } from './lib/primitives/geometry/CubicBezier2d'
|
|
|
352
340
|
export { CubicSpline2d } from './lib/primitives/geometry/CubicSpline2d'
|
|
353
341
|
export { Edge2d } from './lib/primitives/geometry/Edge2d'
|
|
354
342
|
export { Ellipse2d } from './lib/primitives/geometry/Ellipse2d'
|
|
355
|
-
export { getVerticesCountForArcLength } from './lib/primitives/geometry/geometry-constants'
|
|
356
343
|
export {
|
|
357
344
|
Geometry2d,
|
|
358
345
|
Geometry2dFilters,
|
|
@@ -451,7 +438,6 @@ export {
|
|
|
451
438
|
setPointerCapture,
|
|
452
439
|
stopEventPropagation,
|
|
453
440
|
} from './lib/utils/dom'
|
|
454
|
-
export { EditorAtom } from './lib/utils/EditorAtom'
|
|
455
441
|
export { getIncrementedName } from './lib/utils/getIncrementedName'
|
|
456
442
|
export { getPointerInfo } from './lib/utils/getPointerInfo'
|
|
457
443
|
export { getSvgPathFromPoints } from './lib/utils/getSvgPathFromPoints'
|
package/src/lib/TldrawEditor.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { MigrationSequence, Store } from '@tldraw/store'
|
|
2
2
|
import { TLShape, TLStore, TLStoreSnapshot } from '@tldraw/tlschema'
|
|
3
|
-
import {
|
|
3
|
+
import { Required, annotateError } from '@tldraw/utils'
|
|
4
4
|
import React, {
|
|
5
|
-
memo,
|
|
6
5
|
ReactNode,
|
|
6
|
+
memo,
|
|
7
7
|
useCallback,
|
|
8
8
|
useEffect,
|
|
9
9
|
useLayoutEffect,
|
|
@@ -15,13 +15,13 @@ import React, {
|
|
|
15
15
|
|
|
16
16
|
import classNames from 'classnames'
|
|
17
17
|
import { version } from '../version'
|
|
18
|
-
import { DefaultErrorFallback } from './components/default-components/DefaultErrorFallback'
|
|
19
18
|
import { OptionalErrorBoundary } from './components/ErrorBoundary'
|
|
19
|
+
import { DefaultErrorFallback } from './components/default-components/DefaultErrorFallback'
|
|
20
|
+
import { TLEditorSnapshot } from './config/TLEditorSnapshot'
|
|
20
21
|
import { TLStoreBaseOptions } from './config/createTLStore'
|
|
21
|
-
import {
|
|
22
|
+
import { TLUser, createTLUser } from './config/createTLUser'
|
|
22
23
|
import { TLAnyBindingUtilConstructor } from './config/defaultBindings'
|
|
23
24
|
import { TLAnyShapeUtilConstructor } from './config/defaultShapes'
|
|
24
|
-
import { TLEditorSnapshot } from './config/TLEditorSnapshot'
|
|
25
25
|
import { Editor } from './editor/Editor'
|
|
26
26
|
import { TLStateNodeConstructor } from './editor/tools/StateNode'
|
|
27
27
|
import { TLCameraOptions } from './editor/types/misc-types'
|
|
@@ -39,7 +39,6 @@ import { useForceUpdate } from './hooks/useForceUpdate'
|
|
|
39
39
|
import { useShallowObjectIdentity } from './hooks/useIdentity'
|
|
40
40
|
import { useLocalStore } from './hooks/useLocalStore'
|
|
41
41
|
import { useRefState } from './hooks/useRefState'
|
|
42
|
-
import { useStateAttribute } from './hooks/useStateAttribute'
|
|
43
42
|
import { useZoomCss } from './hooks/useZoomCss'
|
|
44
43
|
import { LicenseProvider } from './license/LicenseProvider'
|
|
45
44
|
import { Watermark } from './license/Watermark'
|
|
@@ -647,7 +646,6 @@ function Layout({ children, onMount }: { children: ReactNode; onMount?: TLOnMoun
|
|
|
647
646
|
useCursor()
|
|
648
647
|
useDarkMode()
|
|
649
648
|
useForceUpdate()
|
|
650
|
-
useStateAttribute()
|
|
651
649
|
useOnMount((editor) => {
|
|
652
650
|
const teardownStore = editor.store.props.onMount(editor)
|
|
653
651
|
const teardownCallback = onMount?.(editor)
|
|
@@ -50,6 +50,12 @@ export function MenuClickCapture() {
|
|
|
50
50
|
// Do nothing unless we're pointing
|
|
51
51
|
if (!rPointerState.current.isDown) return
|
|
52
52
|
|
|
53
|
+
// If we're already dragging, pass on the event as it is
|
|
54
|
+
if (rPointerState.current.isDragging) {
|
|
55
|
+
canvasEvents.onPointerMove?.(e)
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
if (
|
|
54
60
|
// We're pointing, but are we dragging?
|
|
55
61
|
Vec.Dist2(rPointerState.current.start, new Vec(e.clientX, e.clientY)) >
|
|
@@ -69,6 +75,8 @@ export function MenuClickCapture() {
|
|
|
69
75
|
clientY: y,
|
|
70
76
|
button: 0,
|
|
71
77
|
})
|
|
78
|
+
// call the pointer move with the current pointer position
|
|
79
|
+
canvasEvents.onPointerMove?.(e)
|
|
72
80
|
}
|
|
73
81
|
},
|
|
74
82
|
[canvasEvents, editor]
|
|
@@ -7,7 +7,7 @@ export type SVGContainerProps = React.ComponentProps<'svg'>
|
|
|
7
7
|
/** @public @react */
|
|
8
8
|
export function SVGContainer({ children, className = '', ...rest }: SVGContainerProps) {
|
|
9
9
|
return (
|
|
10
|
-
<svg {...rest} className={classNames('tl-svg-container', className)}
|
|
10
|
+
<svg {...rest} className={classNames('tl-svg-container', className)}>
|
|
11
11
|
{children}
|
|
12
12
|
</svg>
|
|
13
13
|
)
|
|
@@ -40,7 +40,7 @@ export const Shape = memo(function Shape({
|
|
|
40
40
|
}) {
|
|
41
41
|
const editor = useEditor()
|
|
42
42
|
|
|
43
|
-
const { ShapeErrorFallback
|
|
43
|
+
const { ShapeErrorFallback } = useEditorComponents()
|
|
44
44
|
|
|
45
45
|
const containerRef = useRef<HTMLDivElement>(null)
|
|
46
46
|
const bgContainerRef = useRef<HTMLDivElement>(null)
|
|
@@ -145,22 +145,37 @@ export const Shape = memo(function Shape({
|
|
|
145
145
|
[editor]
|
|
146
146
|
)
|
|
147
147
|
|
|
148
|
-
if (!shape
|
|
148
|
+
if (!shape) return null
|
|
149
|
+
|
|
150
|
+
const isFilledShape = 'fill' in shape.props && shape.props.fill !== 'none'
|
|
149
151
|
|
|
150
152
|
return (
|
|
151
153
|
<>
|
|
152
154
|
{util.backgroundComponent && (
|
|
153
|
-
<
|
|
155
|
+
<div
|
|
156
|
+
ref={bgContainerRef}
|
|
157
|
+
className="tl-shape tl-shape-background"
|
|
158
|
+
data-shape-type={shape.type}
|
|
159
|
+
data-shape-id={shape.id}
|
|
160
|
+
draggable={false}
|
|
161
|
+
>
|
|
154
162
|
<OptionalErrorBoundary fallback={ShapeErrorFallback} onError={annotateError}>
|
|
155
163
|
<InnerShapeBackground shape={shape} util={util} />
|
|
156
164
|
</OptionalErrorBoundary>
|
|
157
|
-
</
|
|
165
|
+
</div>
|
|
158
166
|
)}
|
|
159
|
-
<
|
|
167
|
+
<div
|
|
168
|
+
ref={containerRef}
|
|
169
|
+
className="tl-shape"
|
|
170
|
+
data-shape-type={shape.type}
|
|
171
|
+
data-shape-is-filled={isFilledShape}
|
|
172
|
+
data-shape-id={shape.id}
|
|
173
|
+
draggable={false}
|
|
174
|
+
>
|
|
160
175
|
<OptionalErrorBoundary fallback={ShapeErrorFallback as any} onError={annotateError}>
|
|
161
176
|
<InnerShape shape={shape} util={util} />
|
|
162
177
|
</OptionalErrorBoundary>
|
|
163
|
-
</
|
|
178
|
+
</div>
|
|
164
179
|
</>
|
|
165
180
|
)
|
|
166
181
|
})
|
|
@@ -21,7 +21,7 @@ export const DefaultBrush = ({ brush, color, opacity, className }: TLBrushProps)
|
|
|
21
21
|
const h = toDomPrecision(Math.max(1, brush.h))
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
|
-
<svg className="tl-overlays__item" ref={rSvg}
|
|
24
|
+
<svg className="tl-overlays__item" ref={rSvg}>
|
|
25
25
|
{color ? (
|
|
26
26
|
<g className="tl-brush" opacity={opacity}>
|
|
27
27
|
<rect width={w} height={h} fill={color} opacity={0.75} />
|
|
@@ -139,7 +139,7 @@ export function DefaultCanvas({ className }: TLCanvasComponentProps) {
|
|
|
139
139
|
data-testid="canvas"
|
|
140
140
|
{...events}
|
|
141
141
|
>
|
|
142
|
-
<svg className="tl-svg-context"
|
|
142
|
+
<svg className="tl-svg-context">
|
|
143
143
|
<defs>
|
|
144
144
|
{shapeSvgDefs}
|
|
145
145
|
<CursorDef />
|
|
@@ -39,12 +39,12 @@ export function DefaultCollaboratorHint({
|
|
|
39
39
|
const cursorHintId = useSharedSafeId('cursor_hint')
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
|
-
<svg ref={rSvg} className={classNames('tl-overlays__item', className)}
|
|
42
|
+
<svg ref={rSvg} className={classNames('tl-overlays__item', className)}>
|
|
43
43
|
<use
|
|
44
44
|
href={`#${cursorHintId}`}
|
|
45
45
|
color={color}
|
|
46
46
|
strokeWidth={3}
|
|
47
|
-
stroke="var(--
|
|
47
|
+
stroke="var(--color-background)"
|
|
48
48
|
/>
|
|
49
49
|
<use href={`#${cursorHintId}`} color={color} opacity={opacity} />
|
|
50
50
|
</svg>
|
|
@@ -33,7 +33,7 @@ export const DefaultCursor = memo(function DefaultCursor({
|
|
|
33
33
|
|
|
34
34
|
return (
|
|
35
35
|
<div ref={rCursor} className={classNames('tl-overlays__item', className)}>
|
|
36
|
-
<svg className="tl-cursor"
|
|
36
|
+
<svg className="tl-cursor">
|
|
37
37
|
<use href={`#${cursorId}`} color={color} />
|
|
38
38
|
</svg>
|
|
39
39
|
{chatMessage ? (
|
|
@@ -75,7 +75,7 @@ export const DefaultErrorFallback: TLErrorFallbackComponent = ({ error, editor }
|
|
|
75
75
|
|
|
76
76
|
// if we can't find a theme class from the app or from a parent, we have
|
|
77
77
|
// to fall back on using a media query:
|
|
78
|
-
if (typeof window !== 'undefined' && window
|
|
78
|
+
if (typeof window !== 'undefined' && 'matchMedia' in window) {
|
|
79
79
|
setIsDarkMode(window.matchMedia('(prefers-color-scheme: dark)').matches)
|
|
80
80
|
}
|
|
81
81
|
}, [isDarkModeFromApp])
|
|
@@ -16,7 +16,7 @@ export function DefaultGrid({ x, y, z, size }: TLGridProps) {
|
|
|
16
16
|
const editor = useEditor()
|
|
17
17
|
const { gridSteps } = editor.options
|
|
18
18
|
return (
|
|
19
|
-
<svg className="tl-grid" version="1.1" xmlns="http://www.w3.org/2000/svg"
|
|
19
|
+
<svg className="tl-grid" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
|
20
20
|
<defs>
|
|
21
21
|
{gridSteps.map(({ min, mid, step }, i) => {
|
|
22
22
|
const s = step * size * z
|
|
@@ -7,9 +7,5 @@ export interface TLHandlesProps {
|
|
|
7
7
|
|
|
8
8
|
/** @public @react */
|
|
9
9
|
export const DefaultHandles = ({ children }: TLHandlesProps) => {
|
|
10
|
-
return
|
|
11
|
-
<svg className="tl-user-handles tl-overlays__item" aria-hidden="true">
|
|
12
|
-
{children}
|
|
13
|
-
</svg>
|
|
14
|
-
)
|
|
10
|
+
return <svg className="tl-user-handles tl-overlays__item">{children}</svg>
|
|
15
11
|
}
|
|
@@ -21,7 +21,7 @@ export function DefaultScribble({ scribble, zoom, color, opacity, className }: T
|
|
|
21
21
|
<path
|
|
22
22
|
className="tl-scribble"
|
|
23
23
|
d={getSvgPathFromPoints(scribble.points, false)}
|
|
24
|
-
stroke={color ?? `var(--
|
|
24
|
+
stroke={color ?? `var(--color-${scribble.color})`}
|
|
25
25
|
fill="none"
|
|
26
26
|
strokeWidth={8 / zoom}
|
|
27
27
|
opacity={opacity ?? scribble.opacity}
|
|
@@ -86,12 +86,8 @@ export const DefaultShapeIndicator = memo(function DefaultShapeIndicator({
|
|
|
86
86
|
}, [hidden])
|
|
87
87
|
|
|
88
88
|
return (
|
|
89
|
-
<svg ref={rIndicator} className={classNames('tl-overlays__item', className)}
|
|
90
|
-
<g
|
|
91
|
-
className="tl-shape-indicator"
|
|
92
|
-
stroke={color ?? 'var(--tl-color-selected)'}
|
|
93
|
-
opacity={opacity}
|
|
94
|
-
>
|
|
89
|
+
<svg ref={rIndicator} className={classNames('tl-overlays__item', className)}>
|
|
90
|
+
<g className="tl-shape-indicator" stroke={color ?? 'var(--color-selected)'} opacity={opacity}>
|
|
95
91
|
<InnerIndicator editor={editor} id={shapeId} />
|
|
96
92
|
</g>
|
|
97
93
|
</svg>
|
|
@@ -163,7 +163,7 @@ export interface TLSnapIndicatorProps {
|
|
|
163
163
|
/** @public @react */
|
|
164
164
|
export function DefaultSnapIndicator({ className, line, zoom }: TLSnapIndicatorProps) {
|
|
165
165
|
return (
|
|
166
|
-
<svg className={classNames('tl-overlays__item', className)}
|
|
166
|
+
<svg className={classNames('tl-overlays__item', className)}>
|
|
167
167
|
{line.type === 'points' ? (
|
|
168
168
|
<PointsSnapIndicator {...line} zoom={zoom} />
|
|
169
169
|
) : line.type === 'gaps' ? (
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import classNames from 'classnames'
|
|
2
|
-
|
|
3
1
|
/** @public @react */
|
|
4
|
-
export function DefaultSpinner(
|
|
2
|
+
export function DefaultSpinner() {
|
|
5
3
|
return (
|
|
6
|
-
<svg
|
|
7
|
-
width={16}
|
|
8
|
-
height={16}
|
|
9
|
-
viewBox="0 0 16 16"
|
|
10
|
-
aria-hidden="false"
|
|
11
|
-
{...props}
|
|
12
|
-
className={classNames('tl-spinner', props.className)}
|
|
13
|
-
>
|
|
4
|
+
<svg width={16} height={16} viewBox="0 0 16 16" aria-hidden="false">
|
|
14
5
|
<g strokeWidth={2} fill="none" fillRule="evenodd">
|
|
15
6
|
<circle strokeOpacity={0.25} cx={8} cy={8} r={7} stroke="currentColor" />
|
|
16
|
-
<path strokeLinecap="round" d="M15 8c0-4.5-4.5-7-7-7" stroke="currentColor"
|
|
7
|
+
<path strokeLinecap="round" d="M15 8c0-4.5-4.5-7-7-7" stroke="currentColor">
|
|
8
|
+
<animateTransform
|
|
9
|
+
attributeName="transform"
|
|
10
|
+
type="rotate"
|
|
11
|
+
from="0 8 8"
|
|
12
|
+
to="360 8 8"
|
|
13
|
+
dur="1s"
|
|
14
|
+
repeatCount="indefinite"
|
|
15
|
+
/>
|
|
16
|
+
</path>
|
|
17
17
|
</g>
|
|
18
18
|
</svg>
|
|
19
19
|
)
|
|
@@ -17,14 +17,12 @@ export interface TLUserPreferences {
|
|
|
17
17
|
// N.B. These are duplicated in TLdrawAppUser.
|
|
18
18
|
locale?: string | null
|
|
19
19
|
animationSpeed?: number | null
|
|
20
|
-
areKeyboardShortcutsEnabled?: boolean | null
|
|
21
20
|
edgeScrollSpeed?: number | null
|
|
22
21
|
colorScheme?: 'light' | 'dark' | 'system'
|
|
23
22
|
isSnapMode?: boolean | null
|
|
24
23
|
isWrapMode?: boolean | null
|
|
25
24
|
isDynamicSizeMode?: boolean | null
|
|
26
25
|
isPasteAtCursorMode?: boolean | null
|
|
27
|
-
showUiLabels?: boolean | null
|
|
28
26
|
}
|
|
29
27
|
|
|
30
28
|
interface UserDataSnapshot {
|
|
@@ -46,14 +44,12 @@ export const userTypeValidator: T.Validator<TLUserPreferences> = T.object<TLUser
|
|
|
46
44
|
// N.B. These are duplicated in TLdrawAppUser.
|
|
47
45
|
locale: T.string.nullable().optional(),
|
|
48
46
|
animationSpeed: T.number.nullable().optional(),
|
|
49
|
-
areKeyboardShortcutsEnabled: T.boolean.nullable().optional(),
|
|
50
47
|
edgeScrollSpeed: T.number.nullable().optional(),
|
|
51
48
|
colorScheme: T.literalEnum('light', 'dark', 'system').optional(),
|
|
52
49
|
isSnapMode: T.boolean.nullable().optional(),
|
|
53
50
|
isWrapMode: T.boolean.nullable().optional(),
|
|
54
51
|
isDynamicSizeMode: T.boolean.nullable().optional(),
|
|
55
52
|
isPasteAtCursorMode: T.boolean.nullable().optional(),
|
|
56
|
-
showUiLabels: T.boolean.nullable().optional(),
|
|
57
53
|
})
|
|
58
54
|
|
|
59
55
|
const Versions = {
|
|
@@ -65,8 +61,6 @@ const Versions = {
|
|
|
65
61
|
AddDynamicSizeMode: 6,
|
|
66
62
|
AllowSystemColorScheme: 7,
|
|
67
63
|
AddPasteAtCursor: 8,
|
|
68
|
-
AddKeyboardShortcuts: 9,
|
|
69
|
-
AddShowUiLabels: 10,
|
|
70
64
|
} as const
|
|
71
65
|
|
|
72
66
|
const CURRENT_VERSION = Math.max(...Object.values(Versions))
|
|
@@ -102,12 +96,6 @@ function migrateSnapshot(data: { version: number; user: any }) {
|
|
|
102
96
|
if (data.version < Versions.AddPasteAtCursor) {
|
|
103
97
|
data.user.isPasteAtCursorMode = false
|
|
104
98
|
}
|
|
105
|
-
if (data.version < Versions.AddKeyboardShortcuts) {
|
|
106
|
-
data.user.areKeyboardShortcutsEnabled = true
|
|
107
|
-
}
|
|
108
|
-
if (data.version < Versions.AddShowUiLabels) {
|
|
109
|
-
data.user.showUiLabels = false
|
|
110
|
-
}
|
|
111
99
|
|
|
112
100
|
// finally
|
|
113
101
|
data.version = CURRENT_VERSION
|
|
@@ -135,7 +123,7 @@ function getRandomColor() {
|
|
|
135
123
|
|
|
136
124
|
/** @internal */
|
|
137
125
|
export function userPrefersReducedMotion() {
|
|
138
|
-
if (typeof window !== 'undefined' && window
|
|
126
|
+
if (typeof window !== 'undefined' && 'matchMedia' in window) {
|
|
139
127
|
return window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches ?? false
|
|
140
128
|
}
|
|
141
129
|
|
|
@@ -151,12 +139,10 @@ export const defaultUserPreferences = Object.freeze({
|
|
|
151
139
|
// N.B. These are duplicated in TLdrawAppUser.
|
|
152
140
|
edgeScrollSpeed: 1,
|
|
153
141
|
animationSpeed: userPrefersReducedMotion() ? 0 : 1,
|
|
154
|
-
areKeyboardShortcutsEnabled: true,
|
|
155
142
|
isSnapMode: false,
|
|
156
143
|
isWrapMode: false,
|
|
157
144
|
isDynamicSizeMode: false,
|
|
158
145
|
isPasteAtCursorMode: false,
|
|
159
|
-
showUiLabels: false,
|
|
160
146
|
colorScheme: 'light',
|
|
161
147
|
}) satisfies Readonly<Omit<TLUserPreferences, 'id'>>
|
|
162
148
|
|