@tldraw/editor 3.16.0-canary.ffdf566dd0a8 → 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 -213
- package/dist-cjs/index.js +1 -8
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +0 -2
- package/dist-cjs/lib/TldrawEditor.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 +1 -1
- 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/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/DefaultShapeIndicator.js +1 -1
- 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 +2 -14
- package/dist-cjs/lib/config/TLUserPreferences.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +52 -107
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +3 -13
- 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/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 +2 -2
- package/dist-cjs/lib/license/Watermark.js.map +2 -2
- package/dist-cjs/lib/options.js +0 -1
- 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 -213
- package/dist-esm/index.mjs +2 -16
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +0 -2
- package/dist-esm/lib/TldrawEditor.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 +1 -1
- 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/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/DefaultShapeIndicator.mjs +1 -1
- 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 +2 -14
- package/dist-esm/lib/config/TLUserPreferences.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +52 -107
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +3 -13
- 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/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 +2 -2
- package/dist-esm/lib/license/Watermark.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +0 -1
- 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 +27 -23
- package/package.json +8 -9
- package/src/index.ts +1 -15
- package/src/lib/TldrawEditor.tsx +0 -2
- 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 +1 -1
- package/src/lib/components/default-components/DefaultCursor.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/DefaultShapeIndicator.tsx +1 -1
- 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 +0 -14
- package/src/lib/editor/Editor.test.ts +0 -407
- package/src/lib/editor/Editor.ts +72 -140
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +0 -34
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +0 -13
- 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/hooks/useEditor.tsx +5 -6
- package/src/lib/hooks/useEditorComponents.tsx +2 -8
- package/src/lib/license/Watermark.tsx +2 -2
- package/src/lib/options.ts +0 -2
- 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/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/editor.css
CHANGED
|
@@ -163,12 +163,11 @@
|
|
|
163
163
|
--color-selected: hsl(214, 84%, 56%);
|
|
164
164
|
--color-selected-contrast: hsl(0, 0%, 100%);
|
|
165
165
|
--color-focus: hsl(219, 65%, 50%);
|
|
166
|
-
--color-tooltip: hsla(200, 14%, 4%, 1);
|
|
167
166
|
/* Text */
|
|
168
167
|
--color-text: hsl(0, 0%, 0%);
|
|
169
168
|
--color-text-0: hsl(0, 0%, 11%);
|
|
170
169
|
--color-text-1: hsl(0, 0%, 18%);
|
|
171
|
-
--color-text-3: hsl(
|
|
170
|
+
--color-text-3: hsl(220, 2%, 65%);
|
|
172
171
|
--color-text-shadow: hsl(0, 0%, 100%);
|
|
173
172
|
--color-text-highlight: hsl(52, 100%, 50%);
|
|
174
173
|
--color-text-highlight-p3: color(display-p3 0.972 0.8205 0.05);
|
|
@@ -219,12 +218,11 @@
|
|
|
219
218
|
--color-selected: hsl(217, 89%, 61%);
|
|
220
219
|
--color-selected-contrast: hsl(0, 0%, 100%);
|
|
221
220
|
--color-focus: hsl(217, 76%, 80%);
|
|
222
|
-
--color-tooltip: hsla(0, 0%, 100%, 1);
|
|
223
221
|
/* Text */
|
|
224
222
|
--color-text: hsl(210, 17%, 98%);
|
|
225
223
|
--color-text-0: hsl(0, 9%, 94%);
|
|
226
224
|
--color-text-1: hsl(0, 0%, 85%);
|
|
227
|
-
--color-text-3: hsl(
|
|
225
|
+
--color-text-3: hsl(210, 6%, 45%);
|
|
228
226
|
--color-text-shadow: hsl(210, 13%, 18%);
|
|
229
227
|
--color-text-highlight: hsl(52, 100%, 41%);
|
|
230
228
|
--color-text-highlight-p3: color(display-p3 0.8078 0.6225 0.0312);
|
|
@@ -776,7 +774,8 @@ input,
|
|
|
776
774
|
position: static;
|
|
777
775
|
}
|
|
778
776
|
|
|
779
|
-
.tl-text-wrapper[data-isediting='false'] .tl-text-input
|
|
777
|
+
.tl-text-wrapper[data-isediting='false'] .tl-text-input,
|
|
778
|
+
.tl-arrow-label[data-isediting='false'] .tl-text-input {
|
|
780
779
|
opacity: 0;
|
|
781
780
|
cursor: var(--tl-cursor-default);
|
|
782
781
|
}
|
|
@@ -969,14 +968,14 @@ input,
|
|
|
969
968
|
font-size: 14px;
|
|
970
969
|
font-weight: 500;
|
|
971
970
|
opacity: 0;
|
|
972
|
-
animation:
|
|
971
|
+
animation: fade-in 0.2s ease-in-out forwards;
|
|
973
972
|
animation-delay: 0.2s;
|
|
974
973
|
position: absolute;
|
|
975
974
|
inset: 0px;
|
|
976
975
|
z-index: var(--layer-canvas-blocker);
|
|
977
976
|
}
|
|
978
977
|
|
|
979
|
-
@keyframes
|
|
978
|
+
@keyframes fade-in {
|
|
980
979
|
0% {
|
|
981
980
|
opacity: 0;
|
|
982
981
|
}
|
|
@@ -985,19 +984,6 @@ input,
|
|
|
985
984
|
}
|
|
986
985
|
}
|
|
987
986
|
|
|
988
|
-
.tl-spinner {
|
|
989
|
-
animation: tl-spin 1s linear infinite;
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
@keyframes tl-spin {
|
|
993
|
-
0% {
|
|
994
|
-
transform: rotate(0deg);
|
|
995
|
-
}
|
|
996
|
-
100% {
|
|
997
|
-
transform: rotate(360deg);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
987
|
/* ---------------------- Brush --------------------- */
|
|
1002
988
|
|
|
1003
989
|
.tl-brush {
|
|
@@ -1189,7 +1175,7 @@ input,
|
|
|
1189
1175
|
|
|
1190
1176
|
/* --------------------- Arrow shape -------------------- */
|
|
1191
1177
|
|
|
1192
|
-
.tl-
|
|
1178
|
+
.tl-arrow-label {
|
|
1193
1179
|
position: absolute;
|
|
1194
1180
|
top: -1px;
|
|
1195
1181
|
left: -1px;
|
|
@@ -1204,15 +1190,33 @@ input,
|
|
|
1204
1190
|
text-shadow: var(--tl-text-outline);
|
|
1205
1191
|
}
|
|
1206
1192
|
|
|
1207
|
-
.tl-
|
|
1193
|
+
.tl-arrow-label[data-isediting='true'] p {
|
|
1194
|
+
opacity: 0;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
.tl-arrow-label__inner {
|
|
1208
1198
|
border-radius: var(--radius-1);
|
|
1209
1199
|
box-sizing: content-box;
|
|
1200
|
+
position: relative;
|
|
1210
1201
|
height: max-content;
|
|
1211
1202
|
width: max-content;
|
|
1203
|
+
pointer-events: none;
|
|
1204
|
+
display: flex;
|
|
1205
|
+
justify-content: center;
|
|
1206
|
+
align-items: center;
|
|
1212
1207
|
}
|
|
1213
1208
|
|
|
1214
|
-
.tl-
|
|
1209
|
+
.tl-arrow-label .tl-arrow {
|
|
1210
|
+
position: relative;
|
|
1215
1211
|
height: max-content;
|
|
1212
|
+
padding: inherit;
|
|
1213
|
+
overflow: visible;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
.tl-arrow-label textarea {
|
|
1217
|
+
padding: inherit;
|
|
1218
|
+
/* Don't allow textarea to be zero width */
|
|
1219
|
+
min-width: 4px;
|
|
1216
1220
|
}
|
|
1217
1221
|
|
|
1218
1222
|
.tl-arrow-hint {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tldraw/editor",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "3.16.0-
|
|
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",
|
|
@@ -49,12 +48,12 @@
|
|
|
49
48
|
"@tiptap/core": "^2.9.1",
|
|
50
49
|
"@tiptap/pm": "^2.9.1",
|
|
51
50
|
"@tiptap/react": "^2.9.1",
|
|
52
|
-
"@tldraw/state": "3.16.0-
|
|
53
|
-
"@tldraw/state-react": "3.16.0-
|
|
54
|
-
"@tldraw/store": "3.16.0-
|
|
55
|
-
"@tldraw/tlschema": "3.16.0-
|
|
56
|
-
"@tldraw/utils": "3.16.0-
|
|
57
|
-
"@tldraw/validate": "3.16.0-
|
|
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",
|
|
58
57
|
"@types/core-js": "^2.5.8",
|
|
59
58
|
"@use-gesture/react": "^10.3.1",
|
|
60
59
|
"classnames": "^2.5.1",
|
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
|
@@ -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)
|
|
@@ -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,7 +39,7 @@ 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}
|
|
@@ -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 ? (
|
|
@@ -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
|
}
|
|
@@ -86,7 +86,7 @@ export const DefaultShapeIndicator = memo(function DefaultShapeIndicator({
|
|
|
86
86
|
}, [hidden])
|
|
87
87
|
|
|
88
88
|
return (
|
|
89
|
-
<svg ref={rIndicator} className={classNames('tl-overlays__item', className)}
|
|
89
|
+
<svg ref={rIndicator} className={classNames('tl-overlays__item', className)}>
|
|
90
90
|
<g className="tl-shape-indicator" stroke={color ?? 'var(--color-selected)'} opacity={opacity}>
|
|
91
91
|
<InnerIndicator editor={editor} id={shapeId} />
|
|
92
92
|
</g>
|
|
@@ -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
|
|
@@ -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
|
|