@tldraw/editor 4.6.0-next.fe1474dc57d8 → 5.0.0
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 +412 -179
- package/dist-cjs/index.js +12 -23
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +3 -0
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/default-components/CanvasOverlays.js +180 -0
- package/dist-cjs/lib/components/default-components/CanvasOverlays.js.map +7 -0
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +44 -249
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +3 -3
- package/dist-cjs/lib/editor/Editor.js +78 -28
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js +98 -0
- package/dist-cjs/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js +14 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js.map +2 -2
- package/dist-cjs/lib/editor/overlays/OverlayManager.js +154 -0
- package/dist-cjs/lib/editor/overlays/OverlayManager.js.map +7 -0
- package/dist-cjs/lib/editor/overlays/OverlayUtil.js +92 -0
- package/dist-cjs/lib/editor/overlays/OverlayUtil.js.map +7 -0
- package/dist-cjs/lib/editor/overlays/ShapeIndicatorOverlayUtil.js +161 -0
- package/dist-cjs/lib/editor/overlays/ShapeIndicatorOverlayUtil.js.map +7 -0
- package/dist-cjs/lib/editor/overlays/getOverlayDisplayValues.js +39 -0
- package/dist-cjs/lib/editor/overlays/getOverlayDisplayValues.js.map +7 -0
- package/dist-cjs/lib/editor/shapes/BaseFrameLikeShapeUtil.js +3 -0
- package/dist-cjs/lib/editor/shapes/BaseFrameLikeShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +25 -23
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +32 -2
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/types/event-types.js.map +2 -2
- package/dist-cjs/lib/exports/fetchCache.js +1 -1
- package/dist-cjs/lib/exports/fetchCache.js.map +2 -2
- package/dist-cjs/lib/hooks/EditorComponentsContext.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +3 -3
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useEditorComponents.js +0 -28
- package/dist-cjs/lib/hooks/useEditorComponents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePeerIds.js +1 -36
- package/dist-cjs/lib/hooks/usePeerIds.js.map +2 -2
- package/dist-cjs/lib/hooks/useShapeCulling.js +2 -1
- package/dist-cjs/lib/hooks/useShapeCulling.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/utils/reparenting.js +20 -7
- package/dist-cjs/lib/utils/reparenting.js.map +2 -2
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js +3 -0
- package/dist-cjs/lib/utils/sync/TLLocalSyncClient.js.map +2 -2
- package/dist-cjs/version.js +4 -4
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +412 -179
- package/dist-esm/index.mjs +19 -41
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +3 -0
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/CanvasOverlays.mjs +160 -0
- package/dist-esm/lib/components/default-components/CanvasOverlays.mjs.map +7 -0
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +45 -250
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +3 -3
- package/dist-esm/lib/editor/Editor.mjs +78 -29
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs +83 -0
- package/dist-esm/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs +14 -0
- package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs.map +2 -2
- package/dist-esm/lib/editor/overlays/OverlayManager.mjs +136 -0
- package/dist-esm/lib/editor/overlays/OverlayManager.mjs.map +7 -0
- package/dist-esm/lib/editor/overlays/OverlayUtil.mjs +72 -0
- package/dist-esm/lib/editor/overlays/OverlayUtil.mjs.map +7 -0
- package/dist-esm/lib/editor/overlays/ShapeIndicatorOverlayUtil.mjs +141 -0
- package/dist-esm/lib/editor/overlays/ShapeIndicatorOverlayUtil.mjs.map +7 -0
- package/dist-esm/lib/editor/overlays/getOverlayDisplayValues.mjs +19 -0
- package/dist-esm/lib/editor/overlays/getOverlayDisplayValues.mjs.map +7 -0
- package/dist-esm/lib/editor/shapes/BaseFrameLikeShapeUtil.mjs +3 -0
- package/dist-esm/lib/editor/shapes/BaseFrameLikeShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +25 -23
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +32 -2
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/editor/types/event-types.mjs.map +2 -2
- package/dist-esm/lib/exports/fetchCache.mjs +2 -2
- package/dist-esm/lib/exports/fetchCache.mjs.map +2 -2
- package/dist-esm/lib/hooks/EditorComponentsContext.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +3 -3
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useEditorComponents.mjs +0 -28
- package/dist-esm/lib/hooks/useEditorComponents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePeerIds.mjs +2 -40
- package/dist-esm/lib/hooks/usePeerIds.mjs.map +2 -2
- package/dist-esm/lib/hooks/useShapeCulling.mjs +2 -1
- package/dist-esm/lib/hooks/useShapeCulling.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/utils/reparenting.mjs +20 -7
- package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs +3 -0
- package/dist-esm/lib/utils/sync/TLLocalSyncClient.mjs.map +2 -2
- package/dist-esm/version.mjs +4 -4
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +4 -239
- package/package.json +7 -7
- package/src/index.ts +17 -39
- package/src/lib/TldrawEditor.tsx +9 -0
- package/src/lib/components/default-components/CanvasOverlays.tsx +208 -0
- package/src/lib/components/default-components/DefaultCanvas.tsx +49 -324
- package/src/lib/editor/Editor.test.ts +3 -1
- package/src/lib/editor/Editor.ts +80 -24
- package/src/lib/editor/managers/CollaboratorsManager/CollaboratorsManager.ts +98 -0
- package/src/lib/editor/managers/ThemeManager/defaultThemes.ts +14 -0
- package/src/lib/editor/overlays/OverlayManager.ts +183 -0
- package/src/lib/editor/overlays/OverlayUtil.ts +143 -0
- package/src/lib/editor/overlays/ShapeIndicatorOverlayUtil.ts +216 -0
- package/src/lib/editor/overlays/getOverlayDisplayValues.ts +51 -0
- package/src/lib/editor/shapes/BaseFrameLikeShapeUtil.tsx +9 -2
- package/src/lib/editor/shapes/ShapeUtil.ts +34 -26
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +40 -3
- package/src/lib/editor/types/event-types.ts +2 -0
- package/src/lib/exports/fetchCache.ts +2 -4
- package/src/lib/exports/getSvgJsx.test.ts +3 -1
- package/src/lib/hooks/EditorComponentsContext.tsx +0 -27
- package/src/lib/hooks/useCanvasEvents.ts +13 -8
- package/src/lib/hooks/useEditorComponents.tsx +0 -28
- package/src/lib/hooks/usePeerIds.ts +6 -55
- package/src/lib/hooks/useShapeCulling.tsx +3 -1
- package/src/lib/options.ts +0 -7
- package/src/lib/utils/reparenting.ts +22 -9
- package/src/lib/utils/sync/TLLocalSyncClient.ts +3 -0
- package/src/version.ts +4 -4
- package/dist-cjs/lib/components/GeometryDebuggingView.js +0 -115
- package/dist-cjs/lib/components/GeometryDebuggingView.js.map +0 -7
- package/dist-cjs/lib/components/LiveCollaborators.js +0 -152
- package/dist-cjs/lib/components/LiveCollaborators.js.map +0 -7
- package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js +0 -234
- package/dist-cjs/lib/components/default-components/CanvasShapeIndicators.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultBrush.js +0 -38
- package/dist-cjs/lib/components/default-components/DefaultBrush.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js +0 -71
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultCursor.js +0 -59
- package/dist-cjs/lib/components/default-components/DefaultCursor.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultHandle.js +0 -56
- package/dist-cjs/lib/components/default-components/DefaultHandle.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultHandles.js +0 -28
- package/dist-cjs/lib/components/default-components/DefaultHandles.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultScribble.js +0 -51
- package/dist-cjs/lib/components/default-components/DefaultScribble.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultSelectionForeground.js +0 -69
- package/dist-cjs/lib/components/default-components/DefaultSelectionForeground.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +0 -107
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicatorErrorFallback.js +0 -28
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicatorErrorFallback.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js +0 -102
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicators.js.map +0 -7
- package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js +0 -170
- package/dist-cjs/lib/components/default-components/DefaultSnapIndictor.js.map +0 -7
- package/dist-cjs/lib/hooks/useHandleEvents.js +0 -100
- package/dist-cjs/lib/hooks/useHandleEvents.js.map +0 -7
- package/dist-cjs/lib/hooks/useSelectionEvents.js +0 -98
- package/dist-cjs/lib/hooks/useSelectionEvents.js.map +0 -7
- package/dist-esm/lib/components/GeometryDebuggingView.mjs +0 -95
- package/dist-esm/lib/components/GeometryDebuggingView.mjs.map +0 -7
- package/dist-esm/lib/components/LiveCollaborators.mjs +0 -135
- package/dist-esm/lib/components/LiveCollaborators.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs +0 -214
- package/dist-esm/lib/components/default-components/CanvasShapeIndicators.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultBrush.mjs +0 -18
- package/dist-esm/lib/components/default-components/DefaultBrush.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs +0 -41
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultCursor.mjs +0 -29
- package/dist-esm/lib/components/default-components/DefaultCursor.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultHandle.mjs +0 -26
- package/dist-esm/lib/components/default-components/DefaultHandle.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultHandles.mjs +0 -8
- package/dist-esm/lib/components/default-components/DefaultHandles.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultScribble.mjs +0 -21
- package/dist-esm/lib/components/default-components/DefaultScribble.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultSelectionForeground.mjs +0 -39
- package/dist-esm/lib/components/default-components/DefaultSelectionForeground.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +0 -77
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultShapeIndicatorErrorFallback.mjs +0 -8
- package/dist-esm/lib/components/default-components/DefaultShapeIndicatorErrorFallback.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs +0 -82
- package/dist-esm/lib/components/default-components/DefaultShapeIndicators.mjs.map +0 -7
- package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs +0 -142
- package/dist-esm/lib/components/default-components/DefaultSnapIndictor.mjs.map +0 -7
- package/dist-esm/lib/hooks/useHandleEvents.mjs +0 -70
- package/dist-esm/lib/hooks/useHandleEvents.mjs.map +0 -7
- package/dist-esm/lib/hooks/useSelectionEvents.mjs +0 -78
- package/dist-esm/lib/hooks/useSelectionEvents.mjs.map +0 -7
- package/src/lib/components/GeometryDebuggingView.tsx +0 -108
- package/src/lib/components/LiveCollaborators.tsx +0 -180
- package/src/lib/components/default-components/CanvasShapeIndicators.tsx +0 -300
- package/src/lib/components/default-components/DefaultBrush.tsx +0 -35
- package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +0 -52
- package/src/lib/components/default-components/DefaultCursor.tsx +0 -59
- package/src/lib/components/default-components/DefaultHandle.tsx +0 -42
- package/src/lib/components/default-components/DefaultHandles.tsx +0 -15
- package/src/lib/components/default-components/DefaultScribble.tsx +0 -31
- package/src/lib/components/default-components/DefaultSelectionForeground.tsx +0 -50
- package/src/lib/components/default-components/DefaultShapeIndicator.tsx +0 -104
- package/src/lib/components/default-components/DefaultShapeIndicatorErrorFallback.tsx +0 -9
- package/src/lib/components/default-components/DefaultShapeIndicators.tsx +0 -118
- package/src/lib/components/default-components/DefaultSnapIndictor.tsx +0 -174
- package/src/lib/hooks/useHandleEvents.ts +0 -88
- package/src/lib/hooks/useSelectionEvents.ts +0 -97
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var CanvasShapeIndicators_exports = {};
|
|
20
|
-
__export(CanvasShapeIndicators_exports, {
|
|
21
|
-
CanvasShapeIndicators: () => CanvasShapeIndicators
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(CanvasShapeIndicators_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
-
var import_state_react = require("@tldraw/state-react");
|
|
26
|
-
var import_store = require("@tldraw/store");
|
|
27
|
-
var import_utils = require("@tldraw/utils");
|
|
28
|
-
var import_react = require("react");
|
|
29
|
-
var import_domUtils = require("../../exports/domUtils");
|
|
30
|
-
var import_useColorMode = require("../../hooks/useColorMode");
|
|
31
|
-
var import_useEditor = require("../../hooks/useEditor");
|
|
32
|
-
var import_usePeerIds = require("../../hooks/usePeerIds");
|
|
33
|
-
function setsEqual(a, b) {
|
|
34
|
-
if (a.size !== b.size) return false;
|
|
35
|
-
for (const item of a) {
|
|
36
|
-
if (!b.has(item)) return false;
|
|
37
|
-
}
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
function arraysEqual(a, b) {
|
|
41
|
-
if (a.length !== b.length) return false;
|
|
42
|
-
for (let i = 0; i < a.length; i++) {
|
|
43
|
-
if (a[i] !== b[i]) return false;
|
|
44
|
-
}
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
function collaboratorIndicatorsEqual(a, b) {
|
|
48
|
-
if (a.length !== b.length) return false;
|
|
49
|
-
for (let i = 0; i < a.length; i++) {
|
|
50
|
-
if (a[i].color !== b[i].color) return false;
|
|
51
|
-
if (!arraysEqual(a[i].shapeIds, b[i].shapeIds)) return false;
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
function renderDataEqual(a, b) {
|
|
56
|
-
return setsEqual(a.idsToDisplay, b.idsToDisplay) && setsEqual(a.renderingShapeIds, b.renderingShapeIds) && arraysEqual(a.hintingShapeIds, b.hintingShapeIds) && collaboratorIndicatorsEqual(a.collaboratorIndicators, b.collaboratorIndicators);
|
|
57
|
-
}
|
|
58
|
-
const indicatorPathCache = (0, import_store.createComputedCache)(
|
|
59
|
-
"indicatorPath",
|
|
60
|
-
(editor, shape) => {
|
|
61
|
-
const util = editor.getShapeUtil(shape);
|
|
62
|
-
return util.getIndicatorPath(shape);
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
const getIndicatorPath = (editor, shape) => {
|
|
66
|
-
return indicatorPathCache.get(editor, shape.id);
|
|
67
|
-
};
|
|
68
|
-
function renderShapeIndicator(ctx, editor, shapeId, renderingShapeIds) {
|
|
69
|
-
if (!renderingShapeIds.has(shapeId)) return false;
|
|
70
|
-
const shape = editor.getShape(shapeId);
|
|
71
|
-
if (!shape || shape.isLocked) return false;
|
|
72
|
-
const pageTransform = editor.getShapePageTransform(shape);
|
|
73
|
-
if (!pageTransform) return false;
|
|
74
|
-
const indicatorPath = getIndicatorPath(editor, shape);
|
|
75
|
-
if (!indicatorPath) return false;
|
|
76
|
-
ctx.save();
|
|
77
|
-
ctx.transform(
|
|
78
|
-
pageTransform.a,
|
|
79
|
-
pageTransform.b,
|
|
80
|
-
pageTransform.c,
|
|
81
|
-
pageTransform.d,
|
|
82
|
-
pageTransform.e,
|
|
83
|
-
pageTransform.f
|
|
84
|
-
);
|
|
85
|
-
renderIndicatorPath(ctx, indicatorPath);
|
|
86
|
-
ctx.restore();
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
function renderIndicatorPath(ctx, indicatorPath) {
|
|
90
|
-
if (indicatorPath instanceof Path2D) {
|
|
91
|
-
ctx.stroke(indicatorPath);
|
|
92
|
-
} else {
|
|
93
|
-
const { path, clipPath, additionalPaths } = indicatorPath;
|
|
94
|
-
if (clipPath) {
|
|
95
|
-
ctx.save();
|
|
96
|
-
ctx.clip(clipPath, "evenodd");
|
|
97
|
-
ctx.stroke(path);
|
|
98
|
-
ctx.restore();
|
|
99
|
-
} else {
|
|
100
|
-
ctx.stroke(path);
|
|
101
|
-
}
|
|
102
|
-
if (additionalPaths) {
|
|
103
|
-
for (const additionalPath of additionalPaths) {
|
|
104
|
-
ctx.stroke(additionalPath);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const CanvasShapeIndicators = (0, import_react.memo)(function CanvasShapeIndicators2() {
|
|
110
|
-
const editor = (0, import_useEditor.useEditor)();
|
|
111
|
-
if (!editor.options.useCanvasIndicators) {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CanvasShapeIndicatorsInner, {});
|
|
115
|
-
});
|
|
116
|
-
const CanvasShapeIndicatorsInner = (0, import_react.memo)(function CanvasShapeIndicatorsInner2() {
|
|
117
|
-
const editor = (0, import_useEditor.useEditor)();
|
|
118
|
-
const canvasRef = (0, import_react.useRef)(null);
|
|
119
|
-
const rSelectedColor = (0, import_react.useRef)(null);
|
|
120
|
-
const colorMode = (0, import_useColorMode.useColorMode)();
|
|
121
|
-
(0, import_react.useEffect)(() => {
|
|
122
|
-
const timer = editor.timers.setTimeout(() => {
|
|
123
|
-
rSelectedColor.current = null;
|
|
124
|
-
}, 0);
|
|
125
|
-
return () => clearTimeout(timer);
|
|
126
|
-
}, [colorMode, editor]);
|
|
127
|
-
const activePeerIds$ = (0, import_usePeerIds.useActivePeerIds$)();
|
|
128
|
-
const $renderData = (0, import_state_react.useComputed)(
|
|
129
|
-
"indicator render data",
|
|
130
|
-
() => {
|
|
131
|
-
const renderingShapeIds = new Set(editor.getRenderingShapes().map((s) => s.id));
|
|
132
|
-
const idsToDisplay = /* @__PURE__ */ new Set();
|
|
133
|
-
const instanceState = editor.getInstanceState();
|
|
134
|
-
const isChangingStyle = instanceState.isChangingStyle;
|
|
135
|
-
const isIdleOrEditing = editor.isInAny("select.idle", "select.editing_shape");
|
|
136
|
-
const isInSelectState = editor.isInAny(
|
|
137
|
-
"select.brushing",
|
|
138
|
-
"select.scribble_brushing",
|
|
139
|
-
"select.pointing_shape",
|
|
140
|
-
"select.pointing_selection",
|
|
141
|
-
"select.pointing_handle"
|
|
142
|
-
);
|
|
143
|
-
if (!isChangingStyle && (isIdleOrEditing || isInSelectState)) {
|
|
144
|
-
for (const id of editor.getSelectedShapeIds()) {
|
|
145
|
-
idsToDisplay.add(id);
|
|
146
|
-
}
|
|
147
|
-
if (isIdleOrEditing && instanceState.isHoveringCanvas && !instanceState.isCoarsePointer) {
|
|
148
|
-
const hovered = editor.getHoveredShapeId();
|
|
149
|
-
if (hovered) idsToDisplay.add(hovered);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
const hintingShapeIds = (0, import_utils.dedupe)(editor.getHintingShapeIds());
|
|
153
|
-
const collaboratorIndicators = [];
|
|
154
|
-
const currentPageId = editor.getCurrentPageId();
|
|
155
|
-
const activePeerIds = activePeerIds$.get();
|
|
156
|
-
const collaborators = editor.getCollaborators();
|
|
157
|
-
for (const peerId of activePeerIds.values()) {
|
|
158
|
-
const presence = collaborators.find((c) => c.userId === peerId);
|
|
159
|
-
if (!presence || presence.currentPageId !== currentPageId) continue;
|
|
160
|
-
const visibleShapeIds = presence.selectedShapeIds.filter(
|
|
161
|
-
(id) => renderingShapeIds.has(id) && !editor.isShapeHidden(id)
|
|
162
|
-
);
|
|
163
|
-
if (visibleShapeIds.length > 0) {
|
|
164
|
-
collaboratorIndicators.push({
|
|
165
|
-
color: presence.color,
|
|
166
|
-
shapeIds: visibleShapeIds
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return {
|
|
171
|
-
idsToDisplay,
|
|
172
|
-
renderingShapeIds,
|
|
173
|
-
hintingShapeIds,
|
|
174
|
-
collaboratorIndicators
|
|
175
|
-
};
|
|
176
|
-
},
|
|
177
|
-
{ isEqual: renderDataEqual },
|
|
178
|
-
[editor, activePeerIds$]
|
|
179
|
-
);
|
|
180
|
-
(0, import_state_react.useQuickReactor)(
|
|
181
|
-
"canvas indicators render",
|
|
182
|
-
() => {
|
|
183
|
-
const canvas = canvasRef.current;
|
|
184
|
-
if (!canvas) return;
|
|
185
|
-
const ctx = canvas.getContext("2d");
|
|
186
|
-
if (!ctx) return;
|
|
187
|
-
const { idsToDisplay, renderingShapeIds, hintingShapeIds, collaboratorIndicators } = $renderData.get();
|
|
188
|
-
const { w, h } = editor.getViewportScreenBounds();
|
|
189
|
-
const dpr = editor.getInstanceState().devicePixelRatio;
|
|
190
|
-
const { x: cx, y: cy, z: zoom } = editor.getCamera();
|
|
191
|
-
const canvasWidth = Math.ceil(w * dpr);
|
|
192
|
-
const canvasHeight = Math.ceil(h * dpr);
|
|
193
|
-
if (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {
|
|
194
|
-
canvas.width = canvasWidth;
|
|
195
|
-
canvas.height = canvasHeight;
|
|
196
|
-
canvas.style.width = `${w}px`;
|
|
197
|
-
canvas.style.height = `${h}px`;
|
|
198
|
-
}
|
|
199
|
-
ctx.resetTransform();
|
|
200
|
-
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
201
|
-
ctx.scale(dpr, dpr);
|
|
202
|
-
ctx.scale(zoom, zoom);
|
|
203
|
-
ctx.translate(cx, cy);
|
|
204
|
-
ctx.lineCap = "round";
|
|
205
|
-
ctx.lineJoin = "round";
|
|
206
|
-
ctx.lineWidth = 1.5 / zoom;
|
|
207
|
-
for (const collaborator of collaboratorIndicators) {
|
|
208
|
-
ctx.strokeStyle = collaborator.color;
|
|
209
|
-
ctx.globalAlpha = 0.7;
|
|
210
|
-
for (const shapeId of collaborator.shapeIds) {
|
|
211
|
-
renderShapeIndicator(ctx, editor, shapeId, renderingShapeIds);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
ctx.globalAlpha = 1;
|
|
215
|
-
if (!rSelectedColor.current) {
|
|
216
|
-
rSelectedColor.current = (0, import_domUtils.getComputedStyle)(canvas).getPropertyValue("--tl-color-selected");
|
|
217
|
-
}
|
|
218
|
-
ctx.strokeStyle = rSelectedColor.current;
|
|
219
|
-
ctx.lineWidth = 1.5 / zoom;
|
|
220
|
-
for (const shapeId of idsToDisplay) {
|
|
221
|
-
renderShapeIndicator(ctx, editor, shapeId, renderingShapeIds);
|
|
222
|
-
}
|
|
223
|
-
if (hintingShapeIds.length > 0) {
|
|
224
|
-
ctx.lineWidth = 2.5 / zoom;
|
|
225
|
-
for (const shapeId of hintingShapeIds) {
|
|
226
|
-
renderShapeIndicator(ctx, editor, shapeId, renderingShapeIds);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
[editor, $renderData]
|
|
231
|
-
);
|
|
232
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("canvas", { ref: canvasRef, className: "tl-canvas-indicators" });
|
|
233
|
-
});
|
|
234
|
-
//# sourceMappingURL=CanvasShapeIndicators.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/lib/components/default-components/CanvasShapeIndicators.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useComputed, useQuickReactor } from '@tldraw/state-react'\nimport { createComputedCache } from '@tldraw/store'\nimport { TLShape, TLShapeId } from '@tldraw/tlschema'\nimport { dedupe } from '@tldraw/utils'\nimport { memo, useEffect, useRef } from 'react'\nimport { Editor } from '../../editor/Editor'\nimport { TLIndicatorPath } from '../../editor/shapes/ShapeUtil'\nimport { getComputedStyle } from '../../exports/domUtils'\nimport { useColorMode } from '../../hooks/useColorMode'\nimport { useEditor } from '../../hooks/useEditor'\nimport { useActivePeerIds$ } from '../../hooks/usePeerIds'\n\ninterface CollaboratorIndicatorData {\n\tcolor: string\n\tshapeIds: TLShapeId[]\n}\n\ninterface RenderData {\n\tidsToDisplay: Set<TLShapeId>\n\trenderingShapeIds: Set<TLShapeId>\n\thintingShapeIds: TLShapeId[]\n\tcollaboratorIndicators: CollaboratorIndicatorData[]\n}\n\nfunction setsEqual<T>(a: Set<T>, b: Set<T>): boolean {\n\tif (a.size !== b.size) return false\n\tfor (const item of a) {\n\t\tif (!b.has(item)) return false\n\t}\n\treturn true\n}\n\nfunction arraysEqual<T>(a: readonly T[], b: readonly T[]): boolean {\n\tif (a.length !== b.length) return false\n\tfor (let i = 0; i < a.length; i++) {\n\t\tif (a[i] !== b[i]) return false\n\t}\n\treturn true\n}\n\nfunction collaboratorIndicatorsEqual(\n\ta: CollaboratorIndicatorData[],\n\tb: CollaboratorIndicatorData[]\n): boolean {\n\tif (a.length !== b.length) return false\n\tfor (let i = 0; i < a.length; i++) {\n\t\tif (a[i].color !== b[i].color) return false\n\t\tif (!arraysEqual(a[i].shapeIds, b[i].shapeIds)) return false\n\t}\n\treturn true\n}\n\nfunction renderDataEqual(a: RenderData, b: RenderData): boolean {\n\treturn (\n\t\tsetsEqual(a.idsToDisplay, b.idsToDisplay) &&\n\t\tsetsEqual(a.renderingShapeIds, b.renderingShapeIds) &&\n\t\tarraysEqual(a.hintingShapeIds, b.hintingShapeIds) &&\n\t\tcollaboratorIndicatorsEqual(a.collaboratorIndicators, b.collaboratorIndicators)\n\t)\n}\n\nconst indicatorPathCache = createComputedCache(\n\t'indicatorPath',\n\t(editor: Editor, shape: TLShape) => {\n\t\tconst util = editor.getShapeUtil(shape)\n\t\treturn util.getIndicatorPath(shape)\n\t}\n)\n\nconst getIndicatorPath = (editor: Editor, shape: TLShape) => {\n\treturn indicatorPathCache.get(editor, shape.id)\n}\n\nfunction renderShapeIndicator(\n\tctx: CanvasRenderingContext2D,\n\teditor: Editor,\n\tshapeId: TLShapeId,\n\trenderingShapeIds: Set<TLShapeId>\n): boolean {\n\tif (!renderingShapeIds.has(shapeId)) return false\n\n\tconst shape = editor.getShape(shapeId)\n\tif (!shape || shape.isLocked) return false\n\n\tconst pageTransform = editor.getShapePageTransform(shape)\n\tif (!pageTransform) return false\n\n\tconst indicatorPath = getIndicatorPath(editor, shape)\n\tif (!indicatorPath) return false\n\n\tctx.save()\n\tctx.transform(\n\t\tpageTransform.a,\n\t\tpageTransform.b,\n\t\tpageTransform.c,\n\t\tpageTransform.d,\n\t\tpageTransform.e,\n\t\tpageTransform.f\n\t)\n\trenderIndicatorPath(ctx, indicatorPath)\n\tctx.restore()\n\n\treturn true\n}\n\nfunction renderIndicatorPath(ctx: CanvasRenderingContext2D, indicatorPath: TLIndicatorPath) {\n\tif (indicatorPath instanceof Path2D) {\n\t\tctx.stroke(indicatorPath)\n\t} else {\n\t\tconst { path, clipPath, additionalPaths } = indicatorPath\n\n\t\tif (clipPath) {\n\t\t\tctx.save()\n\t\t\tctx.clip(clipPath, 'evenodd')\n\t\t\tctx.stroke(path)\n\t\t\tctx.restore()\n\t\t} else {\n\t\t\tctx.stroke(path)\n\t\t}\n\n\t\tif (additionalPaths) {\n\t\t\tfor (const additionalPath of additionalPaths) {\n\t\t\t\tctx.stroke(additionalPath)\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** @internal @react */\nexport const CanvasShapeIndicators = memo(function CanvasShapeIndicators() {\n\tconst editor = useEditor()\n\n\t// Skip canvas indicator rendering when the option is disabled (e.g. A/B test)\n\tif (!editor.options.useCanvasIndicators) {\n\t\treturn null\n\t}\n\n\treturn <CanvasShapeIndicatorsInner />\n})\n\nconst CanvasShapeIndicatorsInner = memo(function CanvasShapeIndicatorsInner() {\n\tconst editor = useEditor()\n\tconst canvasRef = useRef<HTMLCanvasElement>(null)\n\n\t// Cache the selected color to avoid getComputedStyle on every render\n\tconst rSelectedColor = useRef<string | null>(null)\n\tconst colorMode = useColorMode()\n\n\tuseEffect(() => {\n\t\tconst timer = editor.timers.setTimeout(() => {\n\t\t\trSelectedColor.current = null\n\t\t}, 0)\n\t\treturn () => clearTimeout(timer)\n\t}, [colorMode, editor])\n\n\t// Get active peer IDs (already handles time-based state transitions)\n\tconst activePeerIds$ = useActivePeerIds$()\n\n\tconst $renderData = useComputed(\n\t\t'indicator render data',\n\t\t() => {\n\t\t\tconst renderingShapeIds = new Set(editor.getRenderingShapes().map((s) => s.id))\n\n\t\t\t// Compute ids to display for selected/hovered shapes\n\t\t\tconst idsToDisplay = new Set<TLShapeId>()\n\t\t\tconst instanceState = editor.getInstanceState()\n\t\t\tconst isChangingStyle = instanceState.isChangingStyle\n\t\t\tconst isIdleOrEditing = editor.isInAny('select.idle', 'select.editing_shape')\n\t\t\tconst isInSelectState = editor.isInAny(\n\t\t\t\t'select.brushing',\n\t\t\t\t'select.scribble_brushing',\n\t\t\t\t'select.pointing_shape',\n\t\t\t\t'select.pointing_selection',\n\t\t\t\t'select.pointing_handle'\n\t\t\t)\n\n\t\t\tif (!isChangingStyle && (isIdleOrEditing || isInSelectState)) {\n\t\t\t\tfor (const id of editor.getSelectedShapeIds()) {\n\t\t\t\t\tidsToDisplay.add(id)\n\t\t\t\t}\n\t\t\t\tif (isIdleOrEditing && instanceState.isHoveringCanvas && !instanceState.isCoarsePointer) {\n\t\t\t\t\tconst hovered = editor.getHoveredShapeId()\n\t\t\t\t\tif (hovered) idsToDisplay.add(hovered)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Compute hinting shape ids\n\t\t\tconst hintingShapeIds = dedupe(editor.getHintingShapeIds())\n\n\t\t\t// Compute collaborator indicators\n\t\t\tconst collaboratorIndicators: CollaboratorIndicatorData[] = []\n\t\t\tconst currentPageId = editor.getCurrentPageId()\n\t\t\tconst activePeerIds = activePeerIds$.get()\n\n\t\t\tconst collaborators = editor.getCollaborators()\n\t\t\tfor (const peerId of activePeerIds.values()) {\n\t\t\t\t// Skip collaborators on different pages\n\t\t\t\tconst presence = collaborators.find((c) => c.userId === peerId)\n\t\t\t\tif (!presence || presence.currentPageId !== currentPageId) continue\n\n\t\t\t\t// Filter to shapes that are visible and on the current rendering set\n\t\t\t\tconst visibleShapeIds = presence.selectedShapeIds.filter(\n\t\t\t\t\t(id) => renderingShapeIds.has(id) && !editor.isShapeHidden(id)\n\t\t\t\t)\n\n\t\t\t\tif (visibleShapeIds.length > 0) {\n\t\t\t\t\tcollaboratorIndicators.push({\n\t\t\t\t\t\tcolor: presence.color,\n\t\t\t\t\t\tshapeIds: visibleShapeIds,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tidsToDisplay,\n\t\t\t\trenderingShapeIds,\n\t\t\t\thintingShapeIds,\n\t\t\t\tcollaboratorIndicators,\n\t\t\t}\n\t\t},\n\t\t{ isEqual: renderDataEqual },\n\t\t[editor, activePeerIds$]\n\t)\n\n\tuseQuickReactor(\n\t\t'canvas indicators render',\n\t\t() => {\n\t\t\tconst canvas = canvasRef.current\n\t\t\tif (!canvas) return\n\n\t\t\tconst ctx = canvas.getContext('2d')\n\t\t\tif (!ctx) return\n\n\t\t\tconst { idsToDisplay, renderingShapeIds, hintingShapeIds, collaboratorIndicators } =\n\t\t\t\t$renderData.get()\n\n\t\t\tconst { w, h } = editor.getViewportScreenBounds()\n\t\t\tconst dpr = editor.getInstanceState().devicePixelRatio\n\t\t\tconst { x: cx, y: cy, z: zoom } = editor.getCamera()\n\n\t\t\tconst canvasWidth = Math.ceil(w * dpr)\n\t\t\tconst canvasHeight = Math.ceil(h * dpr)\n\n\t\t\tif (canvas.width !== canvasWidth || canvas.height !== canvasHeight) {\n\t\t\t\tcanvas.width = canvasWidth\n\t\t\t\tcanvas.height = canvasHeight\n\t\t\t\tcanvas.style.width = `${w}px`\n\t\t\t\tcanvas.style.height = `${h}px`\n\t\t\t}\n\n\t\t\tctx.resetTransform()\n\t\t\tctx.clearRect(0, 0, canvas.width, canvas.height)\n\n\t\t\tctx.scale(dpr, dpr)\n\t\t\tctx.scale(zoom, zoom)\n\t\t\tctx.translate(cx, cy)\n\n\t\t\tctx.lineCap = 'round'\n\t\t\tctx.lineJoin = 'round'\n\n\t\t\t// Draw collaborator indicators first (underneath local indicators)\n\t\t\t// Use 0.5 opacity to match the original SVG-based collaborator indicators\n\t\t\tctx.lineWidth = 1.5 / zoom\n\t\t\tfor (const collaborator of collaboratorIndicators) {\n\t\t\t\tctx.strokeStyle = collaborator.color\n\t\t\t\tctx.globalAlpha = 0.7\n\t\t\t\tfor (const shapeId of collaborator.shapeIds) {\n\t\t\t\t\trenderShapeIndicator(ctx, editor, shapeId, renderingShapeIds)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Reset alpha for local indicators\n\t\t\tctx.globalAlpha = 1.0\n\n\t\t\t// Use cached color, only call getComputedStyle when cache is empty\n\t\t\tif (!rSelectedColor.current) {\n\t\t\t\trSelectedColor.current = getComputedStyle(canvas).getPropertyValue('--tl-color-selected')\n\t\t\t}\n\n\t\t\tctx.strokeStyle = rSelectedColor.current\n\n\t\t\t// Draw selected/hovered indicators (1.5px stroke)\n\t\t\tctx.lineWidth = 1.5 / zoom\n\t\t\tfor (const shapeId of idsToDisplay) {\n\t\t\t\trenderShapeIndicator(ctx, editor, shapeId, renderingShapeIds)\n\t\t\t}\n\n\t\t\t// Draw hinted indicators with a thicker stroke (2.5px)\n\t\t\tif (hintingShapeIds.length > 0) {\n\t\t\t\tctx.lineWidth = 2.5 / zoom\n\t\t\t\tfor (const shapeId of hintingShapeIds) {\n\t\t\t\t\trenderShapeIndicator(ctx, editor, shapeId, renderingShapeIds)\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[editor, $renderData]\n\t)\n\n\treturn <canvas ref={canvasRef} className=\"tl-canvas-indicators\" />\n})\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyIQ;AAzIR,yBAA6C;AAC7C,mBAAoC;AAEpC,mBAAuB;AACvB,mBAAwC;AAGxC,sBAAiC;AACjC,0BAA6B;AAC7B,uBAA0B;AAC1B,wBAAkC;AAclC,SAAS,UAAa,GAAW,GAAoB;AACpD,MAAI,EAAE,SAAS,EAAE,KAAM,QAAO;AAC9B,aAAW,QAAQ,GAAG;AACrB,QAAI,CAAC,EAAE,IAAI,IAAI,EAAG,QAAO;AAAA,EAC1B;AACA,SAAO;AACR;AAEA,SAAS,YAAe,GAAiB,GAA0B;AAClE,MAAI,EAAE,WAAW,EAAE,OAAQ,QAAO;AAClC,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AAClC,QAAI,EAAE,CAAC,MAAM,EAAE,CAAC,EAAG,QAAO;AAAA,EAC3B;AACA,SAAO;AACR;AAEA,SAAS,4BACR,GACA,GACU;AACV,MAAI,EAAE,WAAW,EAAE,OAAQ,QAAO;AAClC,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AAClC,QAAI,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,MAAO,QAAO;AACtC,QAAI,CAAC,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAG,QAAO;AAAA,EACxD;AACA,SAAO;AACR;AAEA,SAAS,gBAAgB,GAAe,GAAw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@@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var DefaultBrush_exports = {};
|
|
20
|
-
__export(DefaultBrush_exports, {
|
|
21
|
-
DefaultBrush: () => DefaultBrush
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(DefaultBrush_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
-
var import_react = require("react");
|
|
26
|
-
var import_useTransform = require("../../hooks/useTransform");
|
|
27
|
-
var import_utils = require("../../primitives/utils");
|
|
28
|
-
const DefaultBrush = ({ brush, color, opacity, className }) => {
|
|
29
|
-
const rSvg = (0, import_react.useRef)(null);
|
|
30
|
-
(0, import_useTransform.useTransform)(rSvg, brush.x, brush.y);
|
|
31
|
-
const w = (0, import_utils.toDomPrecision)(Math.max(1, brush.w));
|
|
32
|
-
const h = (0, import_utils.toDomPrecision)(Math.max(1, brush.h));
|
|
33
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "tl-overlays__item", ref: rSvg, "aria-hidden": "true", children: color ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { className: "tl-brush", opacity, children: [
|
|
34
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { width: w, height: h, fill: color, opacity: 0.75 }),
|
|
35
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { width: w, height: h, fill: "none", stroke: color, opacity: 0.1 })
|
|
36
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { className: `tl-brush tl-brush__default ${className}`, width: w, height: h }) });
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=DefaultBrush.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/lib/components/default-components/DefaultBrush.tsx"],
|
|
4
|
-
"sourcesContent": ["import { BoxModel } from '@tldraw/tlschema'\nimport { useRef } from 'react'\nimport { useTransform } from '../../hooks/useTransform'\nimport { toDomPrecision } from '../../primitives/utils'\n\n/** @public */\nexport interface TLBrushProps {\n\tuserId?: string\n\tbrush: BoxModel\n\tcolor?: string\n\topacity?: number\n\tclassName?: string\n}\n\n/** @public @react */\nexport const DefaultBrush = ({ brush, color, opacity, className }: TLBrushProps) => {\n\tconst rSvg = useRef<SVGSVGElement>(null)\n\tuseTransform(rSvg, brush.x, brush.y)\n\n\tconst w = toDomPrecision(Math.max(1, brush.w))\n\tconst h = toDomPrecision(Math.max(1, brush.h))\n\n\treturn (\n\t\t<svg className=\"tl-overlays__item\" ref={rSvg} aria-hidden=\"true\">\n\t\t\t{color ? (\n\t\t\t\t<g className=\"tl-brush\" opacity={opacity}>\n\t\t\t\t\t<rect width={w} height={h} fill={color} opacity={0.75} />\n\t\t\t\t\t<rect width={w} height={h} fill=\"none\" stroke={color} opacity={0.1} />\n\t\t\t\t</g>\n\t\t\t) : (\n\t\t\t\t<rect className={`tl-brush tl-brush__default ${className}`} width={w} height={h} />\n\t\t\t)}\n\t\t</svg>\n\t)\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBI;AAxBJ,mBAAuB;AACvB,0BAA6B;AAC7B,mBAA+B;AAYxB,MAAM,eAAe,CAAC,EAAE,OAAO,OAAO,SAAS,UAAU,MAAoB;AACnF,QAAM,WAAO,qBAAsB,IAAI;AACvC,wCAAa,MAAM,MAAM,GAAG,MAAM,CAAC;AAEnC,QAAM,QAAI,6BAAe,KAAK,IAAI,GAAG,MAAM,CAAC,CAAC;AAC7C,QAAM,QAAI,6BAAe,KAAK,IAAI,GAAG,MAAM,CAAC,CAAC;AAE7C,SACC,4CAAC,SAAI,WAAU,qBAAoB,KAAK,MAAM,eAAY,QACxD,kBACA,6CAAC,OAAE,WAAU,YAAW,SACvB;AAAA,gDAAC,UAAK,OAAO,GAAG,QAAQ,GAAG,MAAM,OAAO,SAAS,MAAM;AAAA,IACvD,4CAAC,UAAK,OAAO,GAAG,QAAQ,GAAG,MAAK,QAAO,QAAQ,OAAO,SAAS,KAAK;AAAA,KACrE,IAEA,4CAAC,UAAK,WAAW,8BAA8B,SAAS,IAAI,OAAO,GAAG,QAAQ,GAAG,GAEnF;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var DefaultCollaboratorHint_exports = {};
|
|
30
|
-
__export(DefaultCollaboratorHint_exports, {
|
|
31
|
-
DefaultCollaboratorHint: () => DefaultCollaboratorHint
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(DefaultCollaboratorHint_exports);
|
|
34
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
-
var import_classnames = __toESM(require("classnames"), 1);
|
|
36
|
-
var import_react = require("react");
|
|
37
|
-
var import_useSafeId = require("../../hooks/useSafeId");
|
|
38
|
-
var import_useTransform = require("../../hooks/useTransform");
|
|
39
|
-
var import_utils = require("../../primitives/utils");
|
|
40
|
-
var import_Vec = require("../../primitives/Vec");
|
|
41
|
-
function DefaultCollaboratorHint({
|
|
42
|
-
className,
|
|
43
|
-
zoom,
|
|
44
|
-
point,
|
|
45
|
-
color,
|
|
46
|
-
viewport,
|
|
47
|
-
opacity = 1
|
|
48
|
-
}) {
|
|
49
|
-
const rSvg = (0, import_react.useRef)(null);
|
|
50
|
-
(0, import_useTransform.useTransform)(
|
|
51
|
-
rSvg,
|
|
52
|
-
(0, import_utils.clamp)(point.x, viewport.minX + 5 / zoom, viewport.maxX - 5 / zoom),
|
|
53
|
-
(0, import_utils.clamp)(point.y, viewport.minY + 5 / zoom, viewport.maxY - 5 / zoom),
|
|
54
|
-
1 / zoom,
|
|
55
|
-
import_Vec.Vec.Angle(viewport.center, point)
|
|
56
|
-
);
|
|
57
|
-
const cursorHintId = (0, import_useSafeId.useSharedSafeId)("cursor_hint");
|
|
58
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { ref: rSvg, className: (0, import_classnames.default)("tl-overlays__item", className), "aria-hidden": "true", children: [
|
|
59
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
60
|
-
"use",
|
|
61
|
-
{
|
|
62
|
-
href: `#${cursorHintId}`,
|
|
63
|
-
color,
|
|
64
|
-
strokeWidth: 3,
|
|
65
|
-
stroke: "var(--tl-color-background)"
|
|
66
|
-
}
|
|
67
|
-
),
|
|
68
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("use", { href: `#${cursorHintId}`, color, opacity })
|
|
69
|
-
] });
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=DefaultCollaboratorHint.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/lib/components/default-components/DefaultCollaboratorHint.tsx"],
|
|
4
|
-
"sourcesContent": ["import { VecModel } from '@tldraw/tlschema'\nimport classNames from 'classnames'\nimport { useRef } from 'react'\nimport { useSharedSafeId } from '../../hooks/useSafeId'\nimport { useTransform } from '../../hooks/useTransform'\nimport { Box } from '../../primitives/Box'\nimport { clamp } from '../../primitives/utils'\nimport { Vec } from '../../primitives/Vec'\n\n/** @public */\nexport interface TLCollaboratorHintProps {\n\tuserId: string\n\tclassName?: string\n\tpoint: VecModel\n\tviewport: Box\n\tzoom: number\n\topacity?: number\n\tcolor: string\n}\n\n/** @public @react */\nexport function DefaultCollaboratorHint({\n\tclassName,\n\tzoom,\n\tpoint,\n\tcolor,\n\tviewport,\n\topacity = 1,\n}: TLCollaboratorHintProps) {\n\tconst rSvg = useRef<SVGSVGElement>(null)\n\n\tuseTransform(\n\t\trSvg,\n\t\tclamp(point.x, viewport.minX + 5 / zoom, viewport.maxX - 5 / zoom),\n\t\tclamp(point.y, viewport.minY + 5 / zoom, viewport.maxY - 5 / zoom),\n\t\t1 / zoom,\n\t\tVec.Angle(viewport.center, point)\n\t)\n\tconst cursorHintId = useSharedSafeId('cursor_hint')\n\n\treturn (\n\t\t<svg ref={rSvg} className={classNames('tl-overlays__item', className)} aria-hidden=\"true\">\n\t\t\t<use\n\t\t\t\thref={`#${cursorHintId}`}\n\t\t\t\tcolor={color}\n\t\t\t\tstrokeWidth={3}\n\t\t\t\tstroke=\"var(--tl-color-background)\"\n\t\t\t/>\n\t\t\t<use href={`#${cursorHintId}`} color={color} opacity={opacity} />\n\t\t</svg>\n\t)\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCE;AAxCF,wBAAuB;AACvB,mBAAuB;AACvB,uBAAgC;AAChC,0BAA6B;AAE7B,mBAAsB;AACtB,iBAAoB;AAcb,SAAS,wBAAwB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AACX,GAA4B;AAC3B,QAAM,WAAO,qBAAsB,IAAI;AAEvC;AAAA,IACC;AAAA,QACA,oBAAM,MAAM,GAAG,SAAS,OAAO,IAAI,MAAM,SAAS,OAAO,IAAI,IAAI;AAAA,QACjE,oBAAM,MAAM,GAAG,SAAS,OAAO,IAAI,MAAM,SAAS,OAAO,IAAI,IAAI;AAAA,IACjE,IAAI;AAAA,IACJ,eAAI,MAAM,SAAS,QAAQ,KAAK;AAAA,EACjC;AACA,QAAM,mBAAe,kCAAgB,aAAa;AAElD,SACC,6CAAC,SAAI,KAAK,MAAM,eAAW,kBAAAA,SAAW,qBAAqB,SAAS,GAAG,eAAY,QAClF;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,MAAM,IAAI,YAAY;AAAA,QACtB;AAAA,QACA,aAAa;AAAA,QACb,QAAO;AAAA;AAAA,IACR;AAAA,IACA,4CAAC,SAAI,MAAM,IAAI,YAAY,IAAI,OAAc,SAAkB;AAAA,KAChE;AAEF;",
|
|
6
|
-
"names": ["classNames"]
|
|
7
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var DefaultCursor_exports = {};
|
|
30
|
-
__export(DefaultCursor_exports, {
|
|
31
|
-
DefaultCursor: () => DefaultCursor
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(DefaultCursor_exports);
|
|
34
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
-
var import_classnames = __toESM(require("classnames"), 1);
|
|
36
|
-
var import_react = require("react");
|
|
37
|
-
var import_useSafeId = require("../../hooks/useSafeId");
|
|
38
|
-
var import_useTransform = require("../../hooks/useTransform");
|
|
39
|
-
const DefaultCursor = (0, import_react.memo)(function DefaultCursor2({
|
|
40
|
-
className,
|
|
41
|
-
zoom,
|
|
42
|
-
point,
|
|
43
|
-
color,
|
|
44
|
-
name,
|
|
45
|
-
chatMessage
|
|
46
|
-
}) {
|
|
47
|
-
const rCursor = (0, import_react.useRef)(null);
|
|
48
|
-
(0, import_useTransform.useTransform)(rCursor, point?.x, point?.y, 1 / zoom);
|
|
49
|
-
const cursorId = (0, import_useSafeId.useSharedSafeId)("cursor");
|
|
50
|
-
if (!point) return null;
|
|
51
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref: rCursor, className: (0, import_classnames.default)("tl-overlays__item", className), children: [
|
|
52
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "tl-cursor", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("use", { href: `#${cursorId}`, color }) }),
|
|
53
|
-
chatMessage ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
54
|
-
name && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tl-nametag-title", style: { color }, children: name }),
|
|
55
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tl-nametag-chat", style: { backgroundColor: color }, children: chatMessage })
|
|
56
|
-
] }) : name && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tl-nametag", style: { backgroundColor: color }, children: name })
|
|
57
|
-
] });
|
|
58
|
-
});
|
|
59
|
-
//# sourceMappingURL=DefaultCursor.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/lib/components/default-components/DefaultCursor.tsx"],
|
|
4
|
-
"sourcesContent": ["import { VecModel } from '@tldraw/tlschema'\nimport classNames from 'classnames'\nimport { memo, useRef } from 'react'\nimport { useSharedSafeId } from '../../hooks/useSafeId'\nimport { useTransform } from '../../hooks/useTransform'\n\n/** @public */\nexport interface TLCursorProps {\n\tuserId: string\n\tclassName?: string\n\tpoint: VecModel | null\n\tzoom: number\n\tcolor?: string\n\tname: string | null\n\tchatMessage: string\n}\n\n/** @public @react */\nexport const DefaultCursor = memo(function DefaultCursor({\n\tclassName,\n\tzoom,\n\tpoint,\n\tcolor,\n\tname,\n\tchatMessage,\n}: TLCursorProps) {\n\tconst rCursor = useRef<HTMLDivElement>(null)\n\tuseTransform(rCursor, point?.x, point?.y, 1 / zoom)\n\n\tconst cursorId = useSharedSafeId('cursor')\n\n\tif (!point) return null\n\n\treturn (\n\t\t<div ref={rCursor} className={classNames('tl-overlays__item', className)}>\n\t\t\t<svg className=\"tl-cursor\" aria-hidden=\"true\">\n\t\t\t\t<use href={`#${cursorId}`} color={color} />\n\t\t\t</svg>\n\t\t\t{chatMessage ? (\n\t\t\t\t<>\n\t\t\t\t\t{name && (\n\t\t\t\t\t\t<div className=\"tl-nametag-title\" style={{ color }}>\n\t\t\t\t\t\t\t{name}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t\t<div className=\"tl-nametag-chat\" style={{ backgroundColor: color }}>\n\t\t\t\t\t\t{chatMessage}\n\t\t\t\t\t</div>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\tname && (\n\t\t\t\t\t<div className=\"tl-nametag\" style={{ backgroundColor: color }}>\n\t\t\t\t\t\t{name}\n\t\t\t\t\t</div>\n\t\t\t\t)\n\t\t\t)}\n\t\t</div>\n\t)\n})\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoCI;AAnCJ,wBAAuB;AACvB,mBAA6B;AAC7B,uBAAgC;AAChC,0BAA6B;AActB,MAAM,oBAAgB,mBAAK,SAASA,eAAc;AAAA,EACxD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAkB;AACjB,QAAM,cAAU,qBAAuB,IAAI;AAC3C,wCAAa,SAAS,OAAO,GAAG,OAAO,GAAG,IAAI,IAAI;AAElD,QAAM,eAAW,kCAAgB,QAAQ;AAEzC,MAAI,CAAC,MAAO,QAAO;AAEnB,SACC,6CAAC,SAAI,KAAK,SAAS,eAAW,kBAAAC,SAAW,qBAAqB,SAAS,GACtE;AAAA,gDAAC,SAAI,WAAU,aAAY,eAAY,QACtC,sDAAC,SAAI,MAAM,IAAI,QAAQ,IAAI,OAAc,GAC1C;AAAA,IACC,cACA,4EACE;AAAA,cACA,4CAAC,SAAI,WAAU,oBAAmB,OAAO,EAAE,MAAM,GAC/C,gBACF;AAAA,MAED,4CAAC,SAAI,WAAU,mBAAkB,OAAO,EAAE,iBAAiB,MAAM,GAC/D,uBACF;AAAA,OACD,IAEA,QACC,4CAAC,SAAI,WAAU,cAAa,OAAO,EAAE,iBAAiB,MAAM,GAC1D,gBACF;AAAA,KAGH;AAEF,CAAC;",
|
|
6
|
-
"names": ["DefaultCursor", "classNames"]
|
|
7
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var DefaultHandle_exports = {};
|
|
30
|
-
__export(DefaultHandle_exports, {
|
|
31
|
-
DefaultHandle: () => DefaultHandle
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(DefaultHandle_exports);
|
|
34
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
-
var import_classnames = __toESM(require("classnames"), 1);
|
|
36
|
-
var import_constants = require("../../constants");
|
|
37
|
-
var import_useEditor = require("../../hooks/useEditor");
|
|
38
|
-
function DefaultHandle({ handle, isCoarse, className, zoom }) {
|
|
39
|
-
const editor = (0, import_useEditor.useEditor)();
|
|
40
|
-
const br = (isCoarse ? editor.options.coarseHandleRadius : editor.options.handleRadius) / zoom;
|
|
41
|
-
if (handle.type === "clone") {
|
|
42
|
-
const fr2 = 3 / zoom;
|
|
43
|
-
const path = `M0,${-fr2} A${fr2},${fr2} 0 0,1 0,${fr2}`;
|
|
44
|
-
const index = import_constants.SIDES.indexOf(handle.id);
|
|
45
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { className: (0, import_classnames.default)(`tl-handle tl-handle__${handle.type}`, className), children: [
|
|
46
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "tl-handle__bg", r: br }),
|
|
47
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { className: "tl-handle__fg", d: path, transform: `rotate(${-90 + 90 * index})` })
|
|
48
|
-
] });
|
|
49
|
-
}
|
|
50
|
-
const fr = (handle.type === "create" && isCoarse ? 3 : 4) / Math.max(zoom, 0.25);
|
|
51
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", { className: (0, import_classnames.default)(`tl-handle tl-handle__${handle.type}`, className), children: [
|
|
52
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "tl-handle__bg", r: br }),
|
|
53
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "tl-handle__fg", r: fr })
|
|
54
|
-
] });
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=DefaultHandle.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/lib/components/default-components/DefaultHandle.tsx"],
|
|
4
|
-
"sourcesContent": ["import { TLHandle, TLShapeId } from '@tldraw/tlschema'\nimport classNames from 'classnames'\nimport { SIDES } from '../../constants'\nimport { useEditor } from '../../hooks/useEditor'\n\n/** @public */\nexport interface TLHandleProps {\n\tshapeId: TLShapeId\n\thandle: TLHandle\n\tzoom: number\n\tisCoarse: boolean\n\tclassName?: string\n}\n\n/** @public @react */\nexport function DefaultHandle({ handle, isCoarse, className, zoom }: TLHandleProps) {\n\tconst editor = useEditor()\n\tconst br = (isCoarse ? editor.options.coarseHandleRadius : editor.options.handleRadius) / zoom\n\n\tif (handle.type === 'clone') {\n\t\t// bouba\n\t\tconst fr = 3 / zoom\n\t\tconst path = `M0,${-fr} A${fr},${fr} 0 0,1 0,${fr}`\n\n\t\tconst index = SIDES.indexOf(handle.id as (typeof SIDES)[number])\n\t\treturn (\n\t\t\t<g className={classNames(`tl-handle tl-handle__${handle.type}`, className)}>\n\t\t\t\t<circle className=\"tl-handle__bg\" r={br} />\n\t\t\t\t{/* Half circle */}\n\t\t\t\t<path className=\"tl-handle__fg\" d={path} transform={`rotate(${-90 + 90 * index})`} />\n\t\t\t</g>\n\t\t)\n\t}\n\n\tconst fr = (handle.type === 'create' && isCoarse ? 3 : 4) / Math.max(zoom, 0.25)\n\treturn (\n\t\t<g className={classNames(`tl-handle tl-handle__${handle.type}`, className)}>\n\t\t\t<circle className=\"tl-handle__bg\" r={br} />\n\t\t\t<circle className=\"tl-handle__fg\" r={fr} />\n\t\t</g>\n\t)\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BG;AAzBH,wBAAuB;AACvB,uBAAsB;AACtB,uBAA0B;AAYnB,SAAS,cAAc,EAAE,QAAQ,UAAU,WAAW,KAAK,GAAkB;AACnF,QAAM,aAAS,4BAAU;AACzB,QAAM,MAAM,WAAW,OAAO,QAAQ,qBAAqB,OAAO,QAAQ,gBAAgB;AAE1F,MAAI,OAAO,SAAS,SAAS;AAE5B,UAAMA,MAAK,IAAI;AACf,UAAM,OAAO,MAAM,CAACA,GAAE,KAAKA,GAAE,IAAIA,GAAE,YAAYA,GAAE;AAEjD,UAAM,QAAQ,uBAAM,QAAQ,OAAO,EAA4B;AAC/D,WACC,6CAAC,OAAE,eAAW,kBAAAC,SAAW,wBAAwB,OAAO,IAAI,IAAI,SAAS,GACxE;AAAA,kDAAC,YAAO,WAAU,iBAAgB,GAAG,IAAI;AAAA,MAEzC,4CAAC,UAAK,WAAU,iBAAgB,GAAG,MAAM,WAAW,UAAU,MAAM,KAAK,KAAK,KAAK;AAAA,OACpF;AAAA,EAEF;AAEA,QAAM,MAAM,OAAO,SAAS,YAAY,WAAW,IAAI,KAAK,KAAK,IAAI,MAAM,IAAI;AAC/E,SACC,6CAAC,OAAE,eAAW,kBAAAA,SAAW,wBAAwB,OAAO,IAAI,IAAI,SAAS,GACxE;AAAA,gDAAC,YAAO,WAAU,iBAAgB,GAAG,IAAI;AAAA,IACzC,4CAAC,YAAO,WAAU,iBAAgB,GAAG,IAAI;AAAA,KAC1C;AAEF;",
|
|
6
|
-
"names": ["fr", "classNames"]
|
|
7
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var DefaultHandles_exports = {};
|
|
20
|
-
__export(DefaultHandles_exports, {
|
|
21
|
-
DefaultHandles: () => DefaultHandles
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(DefaultHandles_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
-
const DefaultHandles = ({ children }) => {
|
|
26
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "tl-user-handles tl-overlays__item", "aria-hidden": "true", children });
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=DefaultHandles.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/lib/components/default-components/DefaultHandles.tsx"],
|
|
4
|
-
"sourcesContent": ["import { ReactNode } from 'react'\n\n/** @public */\nexport interface TLHandlesProps {\n\tchildren: ReactNode\n}\n\n/** @public @react */\nexport const DefaultHandles = ({ children }: TLHandlesProps) => {\n\treturn (\n\t\t<svg className=\"tl-user-handles tl-overlays__item\" aria-hidden=\"true\">\n\t\t\t{children}\n\t\t</svg>\n\t)\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUE;AAFK,MAAM,iBAAiB,CAAC,EAAE,SAAS,MAAsB;AAC/D,SACC,4CAAC,SAAI,WAAU,qCAAoC,eAAY,QAC7D,UACF;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var DefaultScribble_exports = {};
|
|
30
|
-
__export(DefaultScribble_exports, {
|
|
31
|
-
DefaultScribble: () => DefaultScribble
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(DefaultScribble_exports);
|
|
34
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
-
var import_classnames = __toESM(require("classnames"), 1);
|
|
36
|
-
var import_getSvgPathFromPoints = require("../../utils/getSvgPathFromPoints");
|
|
37
|
-
function DefaultScribble({ scribble, zoom, color, opacity, className }) {
|
|
38
|
-
if (!scribble.points.length) return null;
|
|
39
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: className ? (0, import_classnames.default)("tl-overlays__item", className) : className, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
40
|
-
"path",
|
|
41
|
-
{
|
|
42
|
-
className: "tl-scribble",
|
|
43
|
-
d: (0, import_getSvgPathFromPoints.getSvgPathFromPoints)(scribble.points, false),
|
|
44
|
-
stroke: color ?? `var(--tl-color-${scribble.color})`,
|
|
45
|
-
fill: "none",
|
|
46
|
-
strokeWidth: 8 / zoom,
|
|
47
|
-
opacity: opacity ?? scribble.opacity
|
|
48
|
-
}
|
|
49
|
-
) });
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=DefaultScribble.js.map
|