@tldraw/editor 4.6.0-internal.e29318c66fb0 → 4.6.0-next.0a51207761bb
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 +850 -118
- package/dist-cjs/index.js +20 -6
- package/dist-cjs/index.js.map +3 -3
- package/dist-cjs/lib/TldrawEditor.js +59 -14
- package/dist-cjs/lib/TldrawEditor.js.map +3 -3
- package/dist-cjs/lib/components/MenuClickCapture.js +16 -1
- package/dist-cjs/lib/components/MenuClickCapture.js.map +2 -2
- package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js +3 -3
- package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.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/config/{createTLUser.js → createTLCurrentUser.js} +9 -9
- package/dist-cjs/lib/config/createTLCurrentUser.js.map +7 -0
- package/dist-cjs/lib/config/createTLStore.js +31 -1
- package/dist-cjs/lib/config/createTLStore.js.map +2 -2
- package/dist-cjs/lib/config/defaultAssets.js +36 -0
- package/dist-cjs/lib/config/defaultAssets.js.map +7 -0
- package/dist-cjs/lib/config/defaultShapes.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +329 -12
- package/dist-cjs/lib/editor/Editor.js.map +3 -3
- package/dist-cjs/lib/editor/assets/AssetUtil.js +66 -0
- package/dist-cjs/lib/editor/assets/AssetUtil.js.map +7 -0
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js +1 -1
- package/dist-cjs/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FontManager/FontManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.js +80 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.js.map +7 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js +466 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/PerformanceManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/perf-types.js +17 -0
- package/dist-cjs/lib/editor/managers/PerformanceManager/perf-types.js.map +7 -0
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js +1 -1
- package/dist-cjs/lib/editor/managers/SnapManager/BoundsSnaps.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SnapManager/HandleSnaps.js.map +2 -2
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js +4 -4
- package/dist-cjs/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js +102 -30
- package/dist-cjs/lib/editor/managers/TextManager/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/ThemeManager/ThemeManager.js +106 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/ThemeManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js +586 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js.map +7 -0
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +6 -4
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +21 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +1 -1
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/shared/getPerfectDashProps.js +6 -0
- package/dist-cjs/lib/editor/shapes/shared/getPerfectDashProps.js.map +2 -2
- package/dist-cjs/lib/editor/tools/StateNode.js +14 -17
- package/dist-cjs/lib/editor/tools/StateNode.js.map +2 -2
- package/dist-cjs/lib/editor/types/SvgExportContext.js.map +2 -2
- package/dist-cjs/lib/editor/types/clipboard-types.js.map +1 -1
- package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
- package/dist-cjs/lib/exports/StyleEmbedder.js +1 -1
- package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
- package/dist-cjs/lib/exports/getSvgJsx.js +12 -7
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/globals/environment.js +18 -1
- package/dist-cjs/lib/globals/environment.js.map +2 -2
- package/dist-cjs/lib/hooks/{useIsDarkMode.js → useColorMode.js} +14 -10
- package/dist-cjs/lib/hooks/useColorMode.js.map +7 -0
- package/dist-cjs/lib/hooks/useCursor.js +3 -7
- package/dist-cjs/lib/hooks/useCursor.js.map +2 -2
- package/dist-cjs/lib/hooks/useDarkMode.js +4 -4
- package/dist-cjs/lib/hooks/useDarkMode.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
- package/dist-cjs/lib/hooks/useGestureEvents.js +171 -127
- package/dist-cjs/lib/hooks/useGestureEvents.js.map +3 -3
- package/dist-cjs/lib/hooks/useLocalStore.js.map +2 -2
- package/dist-cjs/lib/options.js +3 -0
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/primitives/Box.js +1 -1
- package/dist-cjs/lib/primitives/Box.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Arc2d.js +2 -2
- package/dist-cjs/lib/primitives/geometry/Arc2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Circle2d.js +2 -2
- package/dist-cjs/lib/primitives/geometry/Circle2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js +2 -2
- package/dist-cjs/lib/primitives/geometry/Ellipse2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js +4 -3
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Polyline2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Polyline2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Stadium2d.js +1 -1
- package/dist-cjs/lib/primitives/geometry/Stadium2d.js.map +2 -2
- package/dist-cjs/lib/utils/getSvgPathFromPoints.js.map +2 -2
- package/dist-cjs/lib/utils/reparenting.js +2 -1
- package/dist-cjs/lib/utils/reparenting.js.map +2 -2
- package/dist-cjs/lib/utils/richText.js.map +2 -2
- package/dist-cjs/lib/utils/runtime.js +2 -1
- package/dist-cjs/lib/utils/runtime.js.map +2 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +1 -1
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
- package/dist-cjs/lib/utils/sync/hardReset.js +0 -8
- package/dist-cjs/lib/utils/sync/hardReset.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 +850 -118
- package/dist-esm/index.mjs +28 -10
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +62 -14
- package/dist-esm/lib/TldrawEditor.mjs.map +3 -3
- package/dist-esm/lib/components/MenuClickCapture.mjs +16 -1
- package/dist-esm/lib/components/MenuClickCapture.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs +3 -3
- package/dist-esm/lib/components/default-components/CanvasShapeIndicators.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/config/{createTLUser.mjs → createTLCurrentUser.mjs} +6 -6
- package/dist-esm/lib/config/createTLCurrentUser.mjs.map +7 -0
- package/dist-esm/lib/config/createTLStore.mjs +37 -2
- package/dist-esm/lib/config/createTLStore.mjs.map +2 -2
- package/dist-esm/lib/config/defaultAssets.mjs +16 -0
- package/dist-esm/lib/config/defaultAssets.mjs.map +7 -0
- package/dist-esm/lib/config/defaultShapes.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +332 -13
- package/dist-esm/lib/editor/Editor.mjs.map +3 -3
- package/dist-esm/lib/editor/assets/AssetUtil.mjs +46 -0
- package/dist-esm/lib/editor/assets/AssetUtil.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs +1 -1
- package/dist-esm/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FontManager/FontManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.mjs +60 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs +438 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/PerformanceManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/perf-types.mjs +1 -0
- package/dist-esm/lib/editor/managers/PerformanceManager/perf-types.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs +1 -1
- package/dist-esm/lib/editor/managers/SnapManager/BoundsSnaps.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SnapManager/HandleSnaps.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs +4 -4
- package/dist-esm/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs +102 -30
- package/dist-esm/lib/editor/managers/TextManager/TextManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/ThemeManager/ThemeManager.mjs +88 -0
- package/dist-esm/lib/editor/managers/ThemeManager/ThemeManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs +568 -0
- package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +6 -4
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +21 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +1 -1
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/shared/getPerfectDashProps.mjs +6 -0
- package/dist-esm/lib/editor/shapes/shared/getPerfectDashProps.mjs.map +2 -2
- package/dist-esm/lib/editor/tools/StateNode.mjs +14 -17
- package/dist-esm/lib/editor/tools/StateNode.mjs.map +2 -2
- package/dist-esm/lib/editor/types/SvgExportContext.mjs.map +2 -2
- package/dist-esm/lib/exports/StyleEmbedder.mjs +1 -1
- package/dist-esm/lib/exports/StyleEmbedder.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs +12 -10
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/globals/environment.mjs +18 -1
- package/dist-esm/lib/globals/environment.mjs.map +2 -2
- package/dist-esm/lib/hooks/useColorMode.mjs +19 -0
- package/dist-esm/lib/hooks/useColorMode.mjs.map +7 -0
- package/dist-esm/lib/hooks/useCursor.mjs +3 -7
- package/dist-esm/lib/hooks/useCursor.mjs.map +2 -2
- package/dist-esm/lib/hooks/useDarkMode.mjs +4 -4
- package/dist-esm/lib/hooks/useDarkMode.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useGestureEvents.mjs +171 -127
- package/dist-esm/lib/hooks/useGestureEvents.mjs.map +3 -3
- package/dist-esm/lib/hooks/useLocalStore.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +3 -0
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/primitives/Box.mjs +1 -1
- package/dist-esm/lib/primitives/Box.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/Ellipse2d.mjs +2 -2
- package/dist-esm/lib/primitives/geometry/Ellipse2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +4 -3
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Polyline2d.mjs +1 -1
- package/dist-esm/lib/primitives/geometry/Polyline2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Stadium2d.mjs +1 -1
- package/dist-esm/lib/primitives/geometry/Stadium2d.mjs.map +2 -2
- package/dist-esm/lib/utils/getSvgPathFromPoints.mjs.map +2 -2
- package/dist-esm/lib/utils/reparenting.mjs +2 -1
- package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
- package/dist-esm/lib/utils/richText.mjs.map +2 -2
- package/dist-esm/lib/utils/runtime.mjs +2 -1
- package/dist-esm/lib/utils/runtime.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +1 -1
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/hardReset.mjs +0 -8
- package/dist-esm/lib/utils/sync/hardReset.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +13 -33
- package/package.json +8 -9
- package/src/index.ts +37 -8
- package/src/lib/TldrawEditor.tsx +99 -20
- package/src/lib/components/MenuClickCapture.tsx +20 -0
- package/src/lib/components/default-components/CanvasShapeIndicators.tsx +3 -3
- package/src/lib/components/default-components/DefaultCanvas.tsx +1 -1
- package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +1 -1
- package/src/lib/config/TLEditorSnapshot.test.ts +1 -1
- package/src/lib/config/{createTLUser.ts → createTLCurrentUser.ts} +6 -6
- package/src/lib/config/createTLStore.ts +58 -3
- package/src/lib/config/defaultAssets.ts +19 -0
- package/src/lib/config/defaultShapes.ts +1 -1
- package/src/lib/editor/Editor.ts +448 -36
- package/src/lib/editor/assets/AssetUtil.ts +85 -0
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.ts +1 -1
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +9 -2
- package/src/lib/editor/managers/FontManager/FontManager.ts +1 -67
- package/src/lib/editor/managers/PerformanceManager/PerformanceApiAdapter.ts +82 -0
- package/src/lib/editor/managers/PerformanceManager/PerformanceManager.test.ts +522 -0
- package/src/lib/editor/managers/PerformanceManager/PerformanceManager.ts +583 -0
- package/src/lib/editor/managers/PerformanceManager/perf-types.ts +196 -0
- package/src/lib/editor/managers/SnapManager/BoundsSnaps.ts +1 -1
- package/src/lib/editor/managers/SnapManager/HandleSnaps.ts +1 -1
- package/src/lib/editor/managers/SpatialIndexManager/SpatialIndexManager.ts +5 -5
- package/src/lib/editor/managers/TextManager/TextManager.test.ts +18 -4
- package/src/lib/editor/managers/TextManager/TextManager.ts +140 -34
- package/src/lib/editor/managers/ThemeManager/ThemeManager.ts +116 -0
- package/src/lib/editor/managers/ThemeManager/defaultThemes.ts +605 -0
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +25 -31
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +7 -5
- package/src/lib/editor/shapes/ShapeUtil.ts +41 -5
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +1 -1
- package/src/lib/editor/shapes/shared/getPerfectDashProps.ts +7 -0
- package/src/lib/editor/tools/StateNode.ts +16 -18
- package/src/lib/editor/types/SvgExportContext.tsx +5 -0
- package/src/lib/editor/types/clipboard-types.ts +2 -1
- package/src/lib/editor/types/external-content.ts +1 -0
- package/src/lib/exports/StyleEmbedder.ts +1 -1
- package/src/lib/exports/getSvgJsx.tsx +22 -16
- package/src/lib/globals/environment.ts +18 -0
- package/src/lib/hooks/{useIsDarkMode.ts → useColorMode.ts} +9 -5
- package/src/lib/hooks/useCursor.ts +3 -7
- package/src/lib/hooks/useDarkMode.ts +4 -4
- package/src/lib/hooks/useEditorComponents.tsx +1 -1
- package/src/lib/hooks/useGestureEvents.ts +240 -168
- package/src/lib/hooks/useLocalStore.ts +1 -1
- package/src/lib/options.ts +108 -0
- package/src/lib/primitives/Box.test.ts +30 -0
- package/src/lib/primitives/Box.ts +1 -1
- package/src/lib/primitives/geometry/Arc2d.ts +2 -2
- package/src/lib/primitives/geometry/Circle2d.ts +2 -2
- package/src/lib/primitives/geometry/Ellipse2d.ts +2 -2
- package/src/lib/primitives/geometry/Geometry2d.test.ts +21 -0
- package/src/lib/primitives/geometry/Geometry2d.ts +4 -3
- package/src/lib/primitives/geometry/Polyline2d.ts +1 -1
- package/src/lib/primitives/geometry/Stadium2d.ts +1 -1
- package/src/lib/utils/getSvgPathFromPoints.ts +1 -1
- package/src/lib/utils/reparenting.ts +6 -2
- package/src/lib/utils/richText.ts +1 -1
- package/src/lib/utils/runtime.ts +3 -1
- package/src/lib/utils/sync/TLLocalSyncClient.test.ts +1 -1
- package/src/lib/utils/sync/TLLocalSyncClient.ts +1 -1
- package/src/lib/utils/sync/hardReset.ts +0 -8
- package/src/version.ts +3 -3
- package/dist-cjs/lib/config/createTLUser.js.map +0 -7
- package/dist-cjs/lib/hooks/useIsDarkMode.js.map +0 -7
- package/dist-esm/lib/config/createTLUser.mjs.map +0 -7
- package/dist-esm/lib/hooks/useIsDarkMode.mjs +0 -15
- package/dist-esm/lib/hooks/useIsDarkMode.mjs.map +0 -7
|
@@ -25,8 +25,10 @@ import {
|
|
|
25
25
|
PageRecordType,
|
|
26
26
|
TLDOCUMENT_ID,
|
|
27
27
|
TLINSTANCE_ID,
|
|
28
|
+
UserRecordType,
|
|
28
29
|
createBindingId,
|
|
29
30
|
createShapeId,
|
|
31
|
+
createUserId,
|
|
30
32
|
getShapePropKeysByStyle,
|
|
31
33
|
isPageId,
|
|
32
34
|
isShapeId
|
|
@@ -62,13 +64,14 @@ import {
|
|
|
62
64
|
uniqueId
|
|
63
65
|
} from "@tldraw/utils";
|
|
64
66
|
import EventEmitter from "eventemitter3";
|
|
67
|
+
import { createTLCurrentUser } from "../config/createTLCurrentUser.mjs";
|
|
68
|
+
import { checkAssets } from "../config/defaultAssets.mjs";
|
|
69
|
+
import { checkBindings } from "../config/defaultBindings.mjs";
|
|
70
|
+
import { checkShapesAndAddCore } from "../config/defaultShapes.mjs";
|
|
65
71
|
import {
|
|
66
72
|
getSnapshot,
|
|
67
73
|
loadSnapshot
|
|
68
74
|
} from "../config/TLEditorSnapshot.mjs";
|
|
69
|
-
import { createTLUser } from "../config/createTLUser.mjs";
|
|
70
|
-
import { checkBindings } from "../config/defaultBindings.mjs";
|
|
71
|
-
import { checkShapesAndAddCore } from "../config/defaultShapes.mjs";
|
|
72
75
|
import {
|
|
73
76
|
DEFAULT_ANIMATION_OPTIONS,
|
|
74
77
|
DEFAULT_CAMERA_OPTIONS,
|
|
@@ -85,13 +88,12 @@ import { tlmenus } from "../globals/menus.mjs";
|
|
|
85
88
|
import { tltime } from "../globals/time.mjs";
|
|
86
89
|
import { defaultTldrawOptions } from "../options.mjs";
|
|
87
90
|
import { Box } from "../primitives/Box.mjs";
|
|
88
|
-
import { Mat } from "../primitives/Mat.mjs";
|
|
89
|
-
import { Vec } from "../primitives/Vec.mjs";
|
|
90
91
|
import { EASINGS } from "../primitives/easings.mjs";
|
|
91
92
|
import { Group2d } from "../primitives/geometry/Group2d.mjs";
|
|
92
93
|
import { intersectPolygonPolygon } from "../primitives/intersect.mjs";
|
|
94
|
+
import { Mat } from "../primitives/Mat.mjs";
|
|
93
95
|
import { PI, approximately, areAnglesCompatible, clamp, pointInPolygon } from "../primitives/utils.mjs";
|
|
94
|
-
import {
|
|
96
|
+
import { Vec } from "../primitives/Vec.mjs";
|
|
95
97
|
import { areShapesContentEqual } from "../utils/areShapesContentEqual.mjs";
|
|
96
98
|
import { dataUrlToFile } from "../utils/assets.mjs";
|
|
97
99
|
import { debugFlags } from "../utils/debug-flags.mjs";
|
|
@@ -103,6 +105,7 @@ import { getIncrementedName } from "../utils/getIncrementedName.mjs";
|
|
|
103
105
|
import { getReorderingShapesChanges } from "../utils/reorderShapes.mjs";
|
|
104
106
|
import { getDroppedShapesToNewParents, kickoutOccludedShapes } from "../utils/reparenting.mjs";
|
|
105
107
|
import { applyRotationToSnapshotShapes, getRotationSnapshot } from "../utils/rotation.mjs";
|
|
108
|
+
import { SharedStyleMap } from "../utils/SharedStylesMap.mjs";
|
|
106
109
|
import { bindingsIndex } from "./derivations/bindingsIndex.mjs";
|
|
107
110
|
import { notVisibleShapes } from "./derivations/notVisibleShapes.mjs";
|
|
108
111
|
import { parentsToChildren } from "./derivations/parentsToChildren.mjs";
|
|
@@ -113,10 +116,12 @@ import { FocusManager } from "./managers/FocusManager/FocusManager.mjs";
|
|
|
113
116
|
import { FontManager } from "./managers/FontManager/FontManager.mjs";
|
|
114
117
|
import { HistoryManager } from "./managers/HistoryManager/HistoryManager.mjs";
|
|
115
118
|
import { InputsManager } from "./managers/InputsManager/InputsManager.mjs";
|
|
119
|
+
import { PerformanceManager } from "./managers/PerformanceManager/PerformanceManager.mjs";
|
|
116
120
|
import { ScribbleManager } from "./managers/ScribbleManager/ScribbleManager.mjs";
|
|
117
121
|
import { SnapManager } from "./managers/SnapManager/SnapManager.mjs";
|
|
118
122
|
import { SpatialIndexManager } from "./managers/SpatialIndexManager/SpatialIndexManager.mjs";
|
|
119
123
|
import { TextManager } from "./managers/TextManager/TextManager.mjs";
|
|
124
|
+
import { resolveThemes, ThemeManager } from "./managers/ThemeManager/ThemeManager.mjs";
|
|
120
125
|
import { TickManager } from "./managers/TickManager/TickManager.mjs";
|
|
121
126
|
import { UserPreferencesManager } from "./managers/UserPreferencesManager/UserPreferencesManager.mjs";
|
|
122
127
|
import { RootState } from "./tools/RootState.mjs";
|
|
@@ -127,6 +132,7 @@ class Editor extends EventEmitter {
|
|
|
127
132
|
user,
|
|
128
133
|
shapeUtils,
|
|
129
134
|
bindingUtils,
|
|
135
|
+
assetUtils: assetUtilConstructors,
|
|
130
136
|
tools,
|
|
131
137
|
getContainer,
|
|
132
138
|
// needs to be here for backwards compatibility with TldrawEditor
|
|
@@ -134,13 +140,15 @@ class Editor extends EventEmitter {
|
|
|
134
140
|
cameraOptions,
|
|
135
141
|
initialState,
|
|
136
142
|
autoFocus,
|
|
137
|
-
inferDarkMode,
|
|
138
143
|
options: _options,
|
|
139
144
|
// needs to be here for backwards compatibility with TldrawEditor
|
|
140
145
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
141
146
|
textOptions: _textOptions,
|
|
142
147
|
getShapeVisibility,
|
|
143
|
-
|
|
148
|
+
colorScheme,
|
|
149
|
+
fontAssetUrls,
|
|
150
|
+
themes,
|
|
151
|
+
initialTheme
|
|
144
152
|
}) {
|
|
145
153
|
super();
|
|
146
154
|
this._getShapeVisibility = getShapeVisibility;
|
|
@@ -163,15 +171,27 @@ class Editor extends EventEmitter {
|
|
|
163
171
|
...cameraOptions,
|
|
164
172
|
...options?.camera
|
|
165
173
|
});
|
|
174
|
+
this.getContainer = getContainer;
|
|
166
175
|
this._textOptions = atom("text options", options?.text ?? null);
|
|
167
|
-
this.user = new UserPreferencesManager(user ??
|
|
176
|
+
this.user = new UserPreferencesManager(user ?? createTLCurrentUser(), colorScheme ?? "light");
|
|
168
177
|
this.disposables.add(() => this.user.dispose());
|
|
169
|
-
this.getContainer = getContainer;
|
|
170
178
|
this.textMeasure = new TextManager(this);
|
|
171
179
|
this.disposables.add(() => this.textMeasure.dispose());
|
|
172
|
-
this.
|
|
180
|
+
this._themeManager = new ThemeManager(this, {
|
|
181
|
+
themes: resolveThemes(themes),
|
|
182
|
+
initial: initialTheme ?? "default"
|
|
183
|
+
});
|
|
184
|
+
this.disposables.add(() => this._themeManager.dispose());
|
|
173
185
|
this._tickManager = new TickManager(this);
|
|
186
|
+
this.disposables.add(() => this._tickManager.dispose());
|
|
187
|
+
this.disposables.add(() => {
|
|
188
|
+
this.off("tick", this._decayCameraStateTimeout);
|
|
189
|
+
this._setCameraState("idle");
|
|
190
|
+
});
|
|
191
|
+
this.fonts = new FontManager(this, fontAssetUrls);
|
|
174
192
|
this.inputs = new InputsManager(this);
|
|
193
|
+
this.performance = new PerformanceManager(this);
|
|
194
|
+
this.disposables.add(() => this.performance.dispose());
|
|
175
195
|
class NewRoot extends RootState {
|
|
176
196
|
static initial = initialState ?? "";
|
|
177
197
|
}
|
|
@@ -199,6 +219,16 @@ class Editor extends EventEmitter {
|
|
|
199
219
|
}
|
|
200
220
|
this.shapeUtils = _shapeUtils;
|
|
201
221
|
this.styleProps = _styleProps;
|
|
222
|
+
const _shapeUtilsByAssetType = {};
|
|
223
|
+
for (const Util of allShapeUtils) {
|
|
224
|
+
const assetTypes = Util.handledAssetTypes;
|
|
225
|
+
if (assetTypes) {
|
|
226
|
+
for (const assetType of assetTypes) {
|
|
227
|
+
_shapeUtilsByAssetType[assetType] = _shapeUtils[Util.type];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
this._shapeUtilsByAssetType = _shapeUtilsByAssetType;
|
|
202
232
|
const allBindingUtils = checkBindings(bindingUtils);
|
|
203
233
|
const _bindingUtils = {};
|
|
204
234
|
for (const Util of allBindingUtils) {
|
|
@@ -206,6 +236,15 @@ class Editor extends EventEmitter {
|
|
|
206
236
|
_bindingUtils[Util.type] = util;
|
|
207
237
|
}
|
|
208
238
|
this.bindingUtils = _bindingUtils;
|
|
239
|
+
if (assetUtilConstructors) {
|
|
240
|
+
const allAssetUtils = checkAssets(assetUtilConstructors);
|
|
241
|
+
const _assetUtils = {};
|
|
242
|
+
for (const Util of allAssetUtils) {
|
|
243
|
+
const util = new Util(this);
|
|
244
|
+
_assetUtils[Util.type] = util;
|
|
245
|
+
}
|
|
246
|
+
this.assetUtils = _assetUtils;
|
|
247
|
+
}
|
|
209
248
|
for (const Tool of [...tools]) {
|
|
210
249
|
if (hasOwnProperty(this.root.children, Tool.id)) {
|
|
211
250
|
throw Error(`Can't override tool with id "${Tool.id}"`);
|
|
@@ -547,6 +586,14 @@ class Editor extends EventEmitter {
|
|
|
547
586
|
})
|
|
548
587
|
);
|
|
549
588
|
}
|
|
589
|
+
this.disposables.add(
|
|
590
|
+
react("sync current user record", () => {
|
|
591
|
+
const user2 = this.store.props.users.currentUser.get();
|
|
592
|
+
if (user2) {
|
|
593
|
+
this._ensureUserRecord(user2);
|
|
594
|
+
}
|
|
595
|
+
})
|
|
596
|
+
);
|
|
550
597
|
}
|
|
551
598
|
_getShapeVisibility;
|
|
552
599
|
getIsShapeHiddenCache() {
|
|
@@ -638,6 +685,17 @@ class Editor extends EventEmitter {
|
|
|
638
685
|
* @public
|
|
639
686
|
*/
|
|
640
687
|
snaps;
|
|
688
|
+
/**
|
|
689
|
+
* A manager for performance measurement hooks.
|
|
690
|
+
*
|
|
691
|
+
* @public
|
|
692
|
+
*/
|
|
693
|
+
performance;
|
|
694
|
+
/**
|
|
695
|
+
* A manager for the spatial index, tracking where shapes exist on the canvas.
|
|
696
|
+
*
|
|
697
|
+
* @internal
|
|
698
|
+
*/
|
|
641
699
|
_spatialIndex;
|
|
642
700
|
/**
|
|
643
701
|
* A manager for the any asynchronous events and making sure they're
|
|
@@ -652,6 +710,12 @@ class Editor extends EventEmitter {
|
|
|
652
710
|
* @public
|
|
653
711
|
*/
|
|
654
712
|
user;
|
|
713
|
+
/**
|
|
714
|
+
* A manager for the editor's themes.
|
|
715
|
+
*
|
|
716
|
+
* @internal
|
|
717
|
+
*/
|
|
718
|
+
_themeManager;
|
|
655
719
|
/**
|
|
656
720
|
* A helper for measuring text.
|
|
657
721
|
*
|
|
@@ -723,12 +787,117 @@ class Editor extends EventEmitter {
|
|
|
723
787
|
* @public
|
|
724
788
|
*/
|
|
725
789
|
dispose() {
|
|
790
|
+
this.stopCameraAnimation();
|
|
791
|
+
if (this.getInstanceState().followingUserId) {
|
|
792
|
+
this.stopFollowingUser();
|
|
793
|
+
}
|
|
726
794
|
this.disposables.forEach((dispose) => dispose());
|
|
727
795
|
this.disposables.clear();
|
|
796
|
+
this.menus.clearOpenMenus();
|
|
728
797
|
this.store.dispose();
|
|
729
798
|
this.isDisposed = true;
|
|
730
799
|
this.emit("dispose");
|
|
731
800
|
}
|
|
801
|
+
/* ------------------ Themes (shadowing the theme manager) ------------------ */
|
|
802
|
+
/**
|
|
803
|
+
* Get the current color mode (`'light'` or `'dark'`), based on the user's dark mode preference.
|
|
804
|
+
*
|
|
805
|
+
* @public
|
|
806
|
+
*/
|
|
807
|
+
getColorMode() {
|
|
808
|
+
return this._themeManager.getColorMode();
|
|
809
|
+
}
|
|
810
|
+
/**
|
|
811
|
+
* Set the color mode. Note that this is a convenience method that passes the mode to
|
|
812
|
+
* `user.updateUserPreferences`, which is the source of truth for the user's color mode preference.
|
|
813
|
+
*
|
|
814
|
+
* @public
|
|
815
|
+
*/
|
|
816
|
+
setColorMode(mode) {
|
|
817
|
+
this.user.updateUserPreferences({ colorScheme: mode });
|
|
818
|
+
return this;
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* Get the id of the current theme.
|
|
822
|
+
*
|
|
823
|
+
* @public
|
|
824
|
+
*/
|
|
825
|
+
getCurrentThemeId() {
|
|
826
|
+
return this._themeManager.getCurrentThemeId();
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Get the current theme definition.
|
|
830
|
+
*
|
|
831
|
+
* @public
|
|
832
|
+
*/
|
|
833
|
+
getCurrentTheme() {
|
|
834
|
+
return this._themeManager.getCurrentTheme();
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* Set the current theme by id.
|
|
838
|
+
*
|
|
839
|
+
* @public
|
|
840
|
+
*/
|
|
841
|
+
setCurrentTheme(id) {
|
|
842
|
+
this._themeManager.setCurrentTheme(id);
|
|
843
|
+
return this;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Get all registered theme definitions.
|
|
847
|
+
*
|
|
848
|
+
* @public
|
|
849
|
+
*/
|
|
850
|
+
getThemes() {
|
|
851
|
+
return this._themeManager.getThemes();
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Get a single theme definition by id.
|
|
855
|
+
*
|
|
856
|
+
* @public
|
|
857
|
+
*/
|
|
858
|
+
getTheme(id) {
|
|
859
|
+
return this._themeManager.getTheme(id);
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Replace all theme definitions, or update them via a callback that receives a deep copy.
|
|
863
|
+
* The `'default'` theme must always be present in the result.
|
|
864
|
+
*
|
|
865
|
+
* @example
|
|
866
|
+
* ```ts
|
|
867
|
+
* // Replace all themes
|
|
868
|
+
* editor.updateThemes({ default: myDefaultTheme, ocean: myOceanTheme })
|
|
869
|
+
*
|
|
870
|
+
* // Update via callback
|
|
871
|
+
* editor.updateThemes((themes) => {
|
|
872
|
+
* delete themes.ocean
|
|
873
|
+
* return themes
|
|
874
|
+
* })
|
|
875
|
+
* ```
|
|
876
|
+
*
|
|
877
|
+
* @public
|
|
878
|
+
*/
|
|
879
|
+
updateThemes(themes) {
|
|
880
|
+
this._themeManager.updateThemes(themes);
|
|
881
|
+
return this;
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Register or update a single theme definition. The theme is keyed by its `id` property.
|
|
885
|
+
*
|
|
886
|
+
* @example
|
|
887
|
+
* ```ts
|
|
888
|
+
* // Override a property on the default theme
|
|
889
|
+
* editor.updateTheme({ ...editor.getTheme('default')!, fontSize: 24 })
|
|
890
|
+
*
|
|
891
|
+
* // Register a new theme
|
|
892
|
+
* editor.updateTheme({ id: 'ocean', ...myOceanTheme })
|
|
893
|
+
* ```
|
|
894
|
+
*
|
|
895
|
+
* @public
|
|
896
|
+
*/
|
|
897
|
+
updateTheme(theme) {
|
|
898
|
+
this._themeManager.updateTheme(theme);
|
|
899
|
+
return this;
|
|
900
|
+
}
|
|
732
901
|
/* ------------------- Shape Utils ------------------ */
|
|
733
902
|
/**
|
|
734
903
|
* A map of shape utility classes (TLShapeUtils) by shape type.
|
|
@@ -736,6 +905,8 @@ class Editor extends EventEmitter {
|
|
|
736
905
|
* @public
|
|
737
906
|
*/
|
|
738
907
|
shapeUtils;
|
|
908
|
+
/** @internal */
|
|
909
|
+
_shapeUtilsByAssetType = {};
|
|
739
910
|
styleProps;
|
|
740
911
|
getShapeUtil(arg) {
|
|
741
912
|
const type = typeof arg === "string" ? arg : arg.type;
|
|
@@ -747,6 +918,17 @@ class Editor extends EventEmitter {
|
|
|
747
918
|
const type = typeof arg === "string" ? arg : arg.type;
|
|
748
919
|
return hasOwnProperty(this.shapeUtils, type);
|
|
749
920
|
}
|
|
921
|
+
/**
|
|
922
|
+
* Get the shape util that handles the given asset type.
|
|
923
|
+
* Returns the shape util whose {@link ShapeUtil.handledAssetTypes} includes
|
|
924
|
+
* the given asset type, or undefined if none matches.
|
|
925
|
+
*
|
|
926
|
+
* @param assetType - The asset type string.
|
|
927
|
+
* @public
|
|
928
|
+
*/
|
|
929
|
+
getShapeUtilForAssetType(assetType) {
|
|
930
|
+
return getOwnProperty(this._shapeUtilsByAssetType, assetType);
|
|
931
|
+
}
|
|
750
932
|
/* ------------------- Binding Utils ------------------ */
|
|
751
933
|
/**
|
|
752
934
|
* A map of shape utility classes (TLShapeUtils) by shape type.
|
|
@@ -760,6 +942,42 @@ class Editor extends EventEmitter {
|
|
|
760
942
|
assert(bindingUtil, `No binding util found for type "${type}"`);
|
|
761
943
|
return bindingUtil;
|
|
762
944
|
}
|
|
945
|
+
/* ------------------- Asset Utils ------------------ */
|
|
946
|
+
/**
|
|
947
|
+
* A map of asset utility classes by asset type.
|
|
948
|
+
*
|
|
949
|
+
* @public
|
|
950
|
+
*/
|
|
951
|
+
assetUtils = {};
|
|
952
|
+
getAssetUtil(arg) {
|
|
953
|
+
const type = typeof arg === "string" ? arg : arg.type;
|
|
954
|
+
const assetUtil = getOwnProperty(this.assetUtils, type);
|
|
955
|
+
assert(assetUtil, `No asset util found for type "${type}"`);
|
|
956
|
+
return assetUtil;
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Returns true if the editor has an asset util for the given asset type.
|
|
960
|
+
*
|
|
961
|
+
* @public
|
|
962
|
+
*/
|
|
963
|
+
hasAssetUtil(arg) {
|
|
964
|
+
const type = typeof arg === "string" ? arg : arg.type;
|
|
965
|
+
return hasOwnProperty(this.assetUtils, type);
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Get the asset util that accepts the given MIME type.
|
|
969
|
+
* Returns null if no registered asset util accepts the MIME type.
|
|
970
|
+
*
|
|
971
|
+
* @public
|
|
972
|
+
*/
|
|
973
|
+
getAssetUtilForMimeType(mimeType) {
|
|
974
|
+
for (const util of Object.values(this.assetUtils)) {
|
|
975
|
+
if (util && util.acceptsMimeType(mimeType)) {
|
|
976
|
+
return util;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
return null;
|
|
980
|
+
}
|
|
763
981
|
/* --------------------- History -------------------- */
|
|
764
982
|
/**
|
|
765
983
|
* A manager for the editor's history.
|
|
@@ -781,6 +999,7 @@ class Editor extends EventEmitter {
|
|
|
781
999
|
this._flushEventsForTick(0);
|
|
782
1000
|
this.complete();
|
|
783
1001
|
this.history.undo();
|
|
1002
|
+
this.performance._notifyUndoRedo("undo", this.history.getNumUndos(), this.history.getNumRedos());
|
|
784
1003
|
return this;
|
|
785
1004
|
}
|
|
786
1005
|
canUndo() {
|
|
@@ -803,6 +1022,7 @@ class Editor extends EventEmitter {
|
|
|
803
1022
|
this._flushEventsForTick(0);
|
|
804
1023
|
this.complete();
|
|
805
1024
|
this.history.redo();
|
|
1025
|
+
this.performance._notifyUndoRedo("redo", this.history.getNumUndos(), this.history.getNumRedos());
|
|
806
1026
|
return this;
|
|
807
1027
|
}
|
|
808
1028
|
canRedo() {
|
|
@@ -2853,6 +3073,76 @@ class Editor extends EventEmitter {
|
|
|
2853
3073
|
const currentPageId = this.getCurrentPageId();
|
|
2854
3074
|
return this.getCollaborators().filter((c) => c.currentPageId === currentPageId);
|
|
2855
3075
|
}
|
|
3076
|
+
// Attribution
|
|
3077
|
+
/**
|
|
3078
|
+
* Get the current user's ID for attribution purposes.
|
|
3079
|
+
* Also ensures a `user:` record exists in the store for the current user.
|
|
3080
|
+
* Returns `null` when the user store has no current user.
|
|
3081
|
+
*
|
|
3082
|
+
* @public
|
|
3083
|
+
*/
|
|
3084
|
+
getAttributionUserId() {
|
|
3085
|
+
const user = this.store.props.users.currentUser.get();
|
|
3086
|
+
if (!user) return null;
|
|
3087
|
+
this._ensureUserRecord(user);
|
|
3088
|
+
return UserRecordType.parseId(user.id);
|
|
3089
|
+
}
|
|
3090
|
+
/**
|
|
3091
|
+
* Ensure a user record exists in the store for the given user,
|
|
3092
|
+
* updating it if the data has changed.
|
|
3093
|
+
*
|
|
3094
|
+
* @internal
|
|
3095
|
+
*/
|
|
3096
|
+
_ensureUserRecord(user) {
|
|
3097
|
+
const existing = this.store.get(user.id);
|
|
3098
|
+
if (existing && existing.name === user.name && existing.color === user.color && existing.imageUrl === user.imageUrl && existing.meta === user.meta) {
|
|
3099
|
+
return;
|
|
3100
|
+
}
|
|
3101
|
+
this.run(
|
|
3102
|
+
() => {
|
|
3103
|
+
this.store.put([user]);
|
|
3104
|
+
},
|
|
3105
|
+
{ history: "ignore" }
|
|
3106
|
+
);
|
|
3107
|
+
}
|
|
3108
|
+
/**
|
|
3109
|
+
* Resolve a display name for a user ID. Asks the
|
|
3110
|
+
* {@link @tldraw/tlschema#TLUserStore} first (the app's source of truth),
|
|
3111
|
+
* falling back to the `user:` record in the store.
|
|
3112
|
+
*
|
|
3113
|
+
* @public
|
|
3114
|
+
*/
|
|
3115
|
+
getAttributionDisplayName(userId) {
|
|
3116
|
+
if (!userId) return null;
|
|
3117
|
+
return this.store.props.users.resolve(userId).get()?.name ?? this.store.get(createUserId(userId))?.name ?? null;
|
|
3118
|
+
}
|
|
3119
|
+
/**
|
|
3120
|
+
* Resolve a user record by ID. Asks the
|
|
3121
|
+
* {@link @tldraw/tlschema#TLUserStore} first (the app's source of truth),
|
|
3122
|
+
* falling back to the `user:` record in the store.
|
|
3123
|
+
*
|
|
3124
|
+
* @public
|
|
3125
|
+
*/
|
|
3126
|
+
getAttributionUser(userId) {
|
|
3127
|
+
if (!userId) return null;
|
|
3128
|
+
return this.store.props.users.resolve(userId).get() ?? this.store.get(createUserId(userId)) ?? null;
|
|
3129
|
+
}
|
|
3130
|
+
/**
|
|
3131
|
+
* Collect user IDs referenced by a set of shapes via shape-specific props
|
|
3132
|
+
* (e.g. `textFirstEditedBy` on notes).
|
|
3133
|
+
*
|
|
3134
|
+
* @internal
|
|
3135
|
+
*/
|
|
3136
|
+
_getReferencedUserIds(shapes) {
|
|
3137
|
+
const userIds = /* @__PURE__ */ new Set();
|
|
3138
|
+
for (const shape of shapes) {
|
|
3139
|
+
const util = this.getShapeUtil(shape);
|
|
3140
|
+
for (const id of util.getReferencedUserIds(shape)) {
|
|
3141
|
+
userIds.add(id);
|
|
3142
|
+
}
|
|
3143
|
+
}
|
|
3144
|
+
return userIds;
|
|
3145
|
+
}
|
|
2856
3146
|
// Following
|
|
2857
3147
|
// When we are 'locked on' to a user, our camera is derived from their camera.
|
|
2858
3148
|
_isLockedOnFollowingUser = atom("isLockedOnFollowingUser", false);
|
|
@@ -6566,12 +6856,22 @@ class Editor extends EventEmitter {
|
|
|
6566
6856
|
if (!asset) continue;
|
|
6567
6857
|
assets.push(asset);
|
|
6568
6858
|
}
|
|
6859
|
+
const users = [];
|
|
6860
|
+
const seenUserIds = /* @__PURE__ */ new Set();
|
|
6861
|
+
for (const userId of this._getReferencedUserIds(shapes2)) {
|
|
6862
|
+
const recordId = createUserId(userId);
|
|
6863
|
+
if (seenUserIds.has(recordId)) continue;
|
|
6864
|
+
seenUserIds.add(recordId);
|
|
6865
|
+
const user = this.store.get(recordId);
|
|
6866
|
+
if (user) users.push(user);
|
|
6867
|
+
}
|
|
6569
6868
|
return {
|
|
6570
6869
|
schema: this.store.schema.serialize(),
|
|
6571
6870
|
shapes: shapes2,
|
|
6572
6871
|
rootShapeIds,
|
|
6573
6872
|
bindings,
|
|
6574
|
-
assets
|
|
6873
|
+
assets,
|
|
6874
|
+
users
|
|
6575
6875
|
};
|
|
6576
6876
|
});
|
|
6577
6877
|
}
|
|
@@ -6621,13 +6921,15 @@ class Editor extends EventEmitter {
|
|
|
6621
6921
|
const assets = [];
|
|
6622
6922
|
const shapes = [];
|
|
6623
6923
|
const bindings = [];
|
|
6924
|
+
const users = [];
|
|
6624
6925
|
const store = {
|
|
6625
6926
|
store: {
|
|
6626
6927
|
...Object.fromEntries(content.assets.map((asset) => [asset.id, asset])),
|
|
6627
6928
|
...Object.fromEntries(content.shapes.map((shape) => [shape.id, shape])),
|
|
6628
6929
|
...Object.fromEntries(
|
|
6629
6930
|
content.bindings?.map((bindings2) => [bindings2.id, bindings2]) ?? []
|
|
6630
|
-
)
|
|
6931
|
+
),
|
|
6932
|
+
...Object.fromEntries(content.users?.map((user) => [user.id, user]) ?? [])
|
|
6631
6933
|
},
|
|
6632
6934
|
schema: content.schema
|
|
6633
6935
|
};
|
|
@@ -6649,6 +6951,19 @@ class Editor extends EventEmitter {
|
|
|
6649
6951
|
bindings.push(record);
|
|
6650
6952
|
break;
|
|
6651
6953
|
}
|
|
6954
|
+
case "user": {
|
|
6955
|
+
users.push(record);
|
|
6956
|
+
break;
|
|
6957
|
+
}
|
|
6958
|
+
}
|
|
6959
|
+
}
|
|
6960
|
+
if (users.length > 0) {
|
|
6961
|
+
const existingUserIds = new Set(
|
|
6962
|
+
this.store.allRecords().filter((r) => r.typeName === "user").map((r) => r.id)
|
|
6963
|
+
);
|
|
6964
|
+
const usersToCreate = users.filter((u) => !existingUserIds.has(u.id));
|
|
6965
|
+
if (usersToCreate.length > 0) {
|
|
6966
|
+
this.store.put(usersToCreate);
|
|
6652
6967
|
}
|
|
6653
6968
|
}
|
|
6654
6969
|
const shapeIdMap = new Map(
|
|
@@ -7614,6 +7929,7 @@ class Editor extends EventEmitter {
|
|
|
7614
7929
|
),
|
|
7615
7930
|
{ immediate: true }
|
|
7616
7931
|
);
|
|
7932
|
+
this.performance._notifyCameraOperation("zooming");
|
|
7617
7933
|
this.emit("event", info);
|
|
7618
7934
|
return;
|
|
7619
7935
|
}
|
|
@@ -7675,6 +7991,7 @@ class Editor extends EventEmitter {
|
|
|
7675
7991
|
immediate: true
|
|
7676
7992
|
});
|
|
7677
7993
|
this.maybeTrackPerformance("Zooming");
|
|
7994
|
+
this.performance._notifyCameraOperation("zooming");
|
|
7678
7995
|
this.root.handleEvent(info);
|
|
7679
7996
|
this.emit("event", info);
|
|
7680
7997
|
return;
|
|
@@ -7684,6 +8001,7 @@ class Editor extends EventEmitter {
|
|
|
7684
8001
|
immediate: true
|
|
7685
8002
|
});
|
|
7686
8003
|
this.maybeTrackPerformance("Panning");
|
|
8004
|
+
this.performance._notifyCameraOperation("panning");
|
|
7687
8005
|
this.root.handleEvent(info);
|
|
7688
8006
|
this.emit("event", info);
|
|
7689
8007
|
return;
|
|
@@ -7749,6 +8067,7 @@ class Editor extends EventEmitter {
|
|
|
7749
8067
|
immediate: true
|
|
7750
8068
|
});
|
|
7751
8069
|
this.maybeTrackPerformance("Panning");
|
|
8070
|
+
this.performance._notifyCameraOperation("panning");
|
|
7752
8071
|
return;
|
|
7753
8072
|
}
|
|
7754
8073
|
if (inputs.getIsPointing() && !inputs.getIsDragging() && Vec.Dist2(inputs.getOriginPagePoint(), inputs.getCurrentPagePoint()) * this.getZoomLevel() > (instanceState.isCoarsePointer ? this.options.coarseDragDistanceSquared : this.options.dragDistanceSquared) / cz) {
|