@mhamz.01/easyflow-whiteboard 2.137.0 → 2.139.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/components/node/custom-node-overlay-fix.d.ts +44 -0
- package/dist/components/node/custom-node-overlay-fix.d.ts.map +1 -1
- package/dist/components/node/custom-node-overlay-fix.js +459 -546
- package/dist/components/node/custom-node-overlay-layer.d.ts +0 -45
- package/dist/components/node/custom-node-overlay-layer.d.ts.map +1 -1
- package/dist/components/node/custom-node-overlay-layer.js +615 -482
- package/dist/components/whiteboard/whiteboard-test.js +2 -2
- package/dist/styles.css +0 -2
- package/package.json +1 -1
|
@@ -1,482 +1,615 @@
|
|
|
1
|
-
"use
|
|
2
|
-
|
|
3
|
-
import React, { useState, useEffect, useRef } from "react";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
//
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// "use client";
|
|
3
|
+
// import React, { useState, useEffect, useRef } from "react";
|
|
4
|
+
// import { FabricObject, Canvas } from "fabric";
|
|
5
|
+
// import TaskNode from "./custom-node";
|
|
6
|
+
// import DocumentNode from "./document-node";
|
|
7
|
+
// export interface Task {
|
|
8
|
+
// id: string;
|
|
9
|
+
// title: string;
|
|
10
|
+
// status: "todo" | "in-progress" | "done";
|
|
11
|
+
// x: number;
|
|
12
|
+
// y: number;
|
|
13
|
+
// assignee?: string;
|
|
14
|
+
// project?: string;
|
|
15
|
+
// priority?: "low" | "medium" | "high";
|
|
16
|
+
// dueDate?: string;
|
|
17
|
+
// }
|
|
18
|
+
// export interface Document {
|
|
19
|
+
// id: string;
|
|
20
|
+
// title: string;
|
|
21
|
+
// project: string;
|
|
22
|
+
// breadcrumb?: string[];
|
|
23
|
+
// preview: string;
|
|
24
|
+
// updatedAt?: string;
|
|
25
|
+
// x: number;
|
|
26
|
+
// y: number;
|
|
27
|
+
// }
|
|
28
|
+
// interface CanvasOverlayLayerProps {
|
|
29
|
+
// tasks: Task[];
|
|
30
|
+
// documents: Document[];
|
|
31
|
+
// onTasksUpdate?: (tasks: Task[]) => void;
|
|
32
|
+
// onDocumentsUpdate?: (documents: Document[]) => void;
|
|
33
|
+
// canvasZoom?: number;
|
|
34
|
+
// canvasViewport?: { x: number; y: number };
|
|
35
|
+
// selectionBox?: { x1: number; y1: number; x2: number; y2: number } | null;
|
|
36
|
+
// selectedCanvasObjects?: FabricObject[];
|
|
37
|
+
// fabricCanvas?: React.RefObject<Canvas | null>;
|
|
38
|
+
// canvasReady?: boolean;
|
|
39
|
+
// }
|
|
40
|
+
// interface DragState {
|
|
41
|
+
// isDragging: boolean;
|
|
42
|
+
// itemIds: string[];
|
|
43
|
+
// startPositions: Map<string, { x: number; y: number }>;
|
|
44
|
+
// canvasObjectsStartPos: Map<FabricObject, { left: number; top: number }>;
|
|
45
|
+
// offsetX: number;
|
|
46
|
+
// offsetY: number;
|
|
47
|
+
// }
|
|
48
|
+
// // ─── Component ────────────────────────────────────────────────────────────────
|
|
49
|
+
// export default React.memo(function CanvasOverlayLayer({
|
|
50
|
+
// tasks,
|
|
51
|
+
// documents,
|
|
52
|
+
// onTasksUpdate,
|
|
53
|
+
// onDocumentsUpdate,
|
|
54
|
+
// canvasZoom = 1,
|
|
55
|
+
// canvasViewport = { x: 0, y: 0 },
|
|
56
|
+
// selectionBox = null,
|
|
57
|
+
// selectedCanvasObjects = [],
|
|
58
|
+
// fabricCanvas,
|
|
59
|
+
// canvasReady: canvasReadyProp = false,
|
|
60
|
+
// }: CanvasOverlayLayerProps) {
|
|
61
|
+
// const [localTasks, setLocalTasks] = useState<Task[]>(tasks);
|
|
62
|
+
// const [localDocuments, setLocalDocuments] = useState<Document[]>(documents);
|
|
63
|
+
// const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());
|
|
64
|
+
// const [dragging, setDragging] = useState<{ itemIds: string[] } | null>(null);
|
|
65
|
+
// const nodeClipboardRef = useRef<{ tasks: Task[]; documents: Document[] }>({
|
|
66
|
+
// tasks: [],
|
|
67
|
+
// documents: [],
|
|
68
|
+
// });
|
|
69
|
+
// // ── Refs for always-current state (Issue 4) ────────────────────────────────
|
|
70
|
+
// const localTasksRef = useRef(localTasks);
|
|
71
|
+
// const localDocumentsRef = useRef(localDocuments);
|
|
72
|
+
// const selectedIdsRef = useRef<Set<string>>(selectedIds);
|
|
73
|
+
// localTasksRef.current = localTasks;
|
|
74
|
+
// localDocumentsRef.current = localDocuments;
|
|
75
|
+
// selectedIdsRef.current = selectedIds;
|
|
76
|
+
// const dragStateRef = useRef<DragState>({
|
|
77
|
+
// isDragging: false,
|
|
78
|
+
// itemIds: [],
|
|
79
|
+
// startPositions: new Map(),
|
|
80
|
+
// canvasObjectsStartPos: new Map(),
|
|
81
|
+
// offsetX: 0,
|
|
82
|
+
// offsetY: 0,
|
|
83
|
+
// });
|
|
84
|
+
// const rafIdRef = useRef<number | null>(null);
|
|
85
|
+
// const fabricMoveRafRef = useRef<number | null>(null); // Issue 7
|
|
86
|
+
// const overlayRef = useRef<HTMLDivElement>(null);
|
|
87
|
+
// // ── Sync props → local state ────────────────────────────────────────────────
|
|
88
|
+
// useEffect(() => {
|
|
89
|
+
// setLocalTasks(tasks);
|
|
90
|
+
// }, [tasks]);
|
|
91
|
+
// useEffect(() => {
|
|
92
|
+
// setLocalDocuments(documents);
|
|
93
|
+
// }, [documents]);
|
|
94
|
+
// // Issue 2: Remove internal canvasReady state and polling — use prop directly
|
|
95
|
+
// // No longer needed: const [canvasReady, setCanvasReady] = useState(false);
|
|
96
|
+
// // No longer needed: polling useEffect with setInterval
|
|
97
|
+
// // ── Event Forwarding (Fixes Zooming on Nodes) ───────────────────────────────
|
|
98
|
+
// const handleOverlayWheel = (e: React.WheelEvent) => {
|
|
99
|
+
// if (e.ctrlKey || e.metaKey || e.shiftKey) {
|
|
100
|
+
// const canvas = fabricCanvas?.current;
|
|
101
|
+
// if (!canvas) return;
|
|
102
|
+
// const nativeEvent = e.nativeEvent;
|
|
103
|
+
// // getScenePoint handles the transformation from screen to canvas space
|
|
104
|
+
// const scenePoint = canvas.getScenePoint(nativeEvent);
|
|
105
|
+
// // Viewport point is simply the mouse position relative to the canvas element
|
|
106
|
+
// const rect = canvas.getElement().getBoundingClientRect();
|
|
107
|
+
// const viewportPoint = {
|
|
108
|
+
// x: nativeEvent.clientX - rect.left,
|
|
109
|
+
// y: nativeEvent.clientY - rect.top,
|
|
110
|
+
// };
|
|
111
|
+
// // We cast to 'any' here because we are manually triggering an internal
|
|
112
|
+
// // event bus, and Fabric's internal types for .fire() can be overly strict.
|
|
113
|
+
// canvas.fire("mouse:wheel", {
|
|
114
|
+
// e: nativeEvent,
|
|
115
|
+
// scenePoint,
|
|
116
|
+
// viewportPoint,
|
|
117
|
+
// } as any);
|
|
118
|
+
// e.preventDefault();
|
|
119
|
+
// e.stopPropagation();
|
|
120
|
+
// }
|
|
121
|
+
// };
|
|
122
|
+
// // Issue 6: Remove canvasZoom from deps — not used in handler
|
|
123
|
+
// useEffect(() => {
|
|
124
|
+
// const overlayEl = overlayRef.current;
|
|
125
|
+
// const canvas = fabricCanvas?.current;
|
|
126
|
+
// if (!overlayEl || !canvas) return;
|
|
127
|
+
// const handleGlobalWheel = (e: WheelEvent) => {
|
|
128
|
+
// // Check if the user is hovering over an element that has pointer-events: auto
|
|
129
|
+
// // (meaning they are hovering over a Task or Document)
|
|
130
|
+
// const target = e.target as HTMLElement;
|
|
131
|
+
// const isOverNode = target !== overlayEl;
|
|
132
|
+
// if ((e.ctrlKey || e.metaKey) && isOverNode) {
|
|
133
|
+
// // 1. Prevent Browser Zoom immediately
|
|
134
|
+
// e.preventDefault();
|
|
135
|
+
// e.stopPropagation();
|
|
136
|
+
// // 2. Calculate coordinates for Fabric
|
|
137
|
+
// const scenePoint = canvas.getScenePoint(e);
|
|
138
|
+
// const rect = canvas.getElement().getBoundingClientRect();
|
|
139
|
+
// const viewportPoint = {
|
|
140
|
+
// x: e.clientX - rect.left,
|
|
141
|
+
// y: e.clientY - rect.top,
|
|
142
|
+
// };
|
|
143
|
+
// // 3. Manually fire the event into Fabric
|
|
144
|
+
// canvas.fire("mouse:wheel", {
|
|
145
|
+
// e: e,
|
|
146
|
+
// scenePoint,
|
|
147
|
+
// viewportPoint,
|
|
148
|
+
// } as any);
|
|
149
|
+
// }
|
|
150
|
+
// };
|
|
151
|
+
// // CRITICAL: { passive: false } allows us to cancel the browser's zoom
|
|
152
|
+
// overlayEl.addEventListener("wheel", handleGlobalWheel, { passive: false });
|
|
153
|
+
// return () => {
|
|
154
|
+
// overlayEl.removeEventListener("wheel", handleGlobalWheel);
|
|
155
|
+
// };
|
|
156
|
+
// }, [fabricCanvas, canvasReadyProp]); // Issue 6: removed canvasZoom
|
|
157
|
+
// // ── Fabric → Overlay Sync (Fixes Dragging from Fabric area) ──────────────────
|
|
158
|
+
// // Issue 5: Remove canvasZoom from deps — not used in handlers
|
|
159
|
+
// useEffect(() => {
|
|
160
|
+
// const canvas = fabricCanvas?.current;
|
|
161
|
+
// if (!canvas) return;
|
|
162
|
+
// // Issue 7: Throttle handleObjectMoving with rAF gate
|
|
163
|
+
// const handleObjectMoving = (e: any) => {
|
|
164
|
+
// const target = e.transform?.target || e.target;
|
|
165
|
+
// if (!target) return;
|
|
166
|
+
// const deltaX = target.left - (target._prevLeft ?? target.left);
|
|
167
|
+
// const deltaY = target.top - (target._prevTop ?? target.top);
|
|
168
|
+
// target._prevLeft = target.left;
|
|
169
|
+
// target._prevTop = target.top;
|
|
170
|
+
// if (deltaX === 0 && deltaY === 0) return;
|
|
171
|
+
// const sel = selectedIdsRef.current;
|
|
172
|
+
// // Skip if frame already queued
|
|
173
|
+
// if (fabricMoveRafRef.current !== null) return;
|
|
174
|
+
// fabricMoveRafRef.current = requestAnimationFrame(() => {
|
|
175
|
+
// fabricMoveRafRef.current = null;
|
|
176
|
+
// setLocalTasks((prev) =>
|
|
177
|
+
// prev.map((t) =>
|
|
178
|
+
// sel.has(t.id)
|
|
179
|
+
// ? { ...t, x: t.x + deltaX, y: t.y + deltaY }
|
|
180
|
+
// : t
|
|
181
|
+
// )
|
|
182
|
+
// );
|
|
183
|
+
// setLocalDocuments((prev) =>
|
|
184
|
+
// prev.map((d) =>
|
|
185
|
+
// sel.has(d.id)
|
|
186
|
+
// ? { ...d, x: d.x + deltaX, y: d.y + deltaY }
|
|
187
|
+
// : d
|
|
188
|
+
// )
|
|
189
|
+
// );
|
|
190
|
+
// });
|
|
191
|
+
// };
|
|
192
|
+
// const handleMouseDown = (e: any) => {
|
|
193
|
+
// const target = e.target;
|
|
194
|
+
// if (target) {
|
|
195
|
+
// target._prevLeft = target.left;
|
|
196
|
+
// target._prevTop = target.top;
|
|
197
|
+
// }
|
|
198
|
+
// if (!target) {
|
|
199
|
+
// setSelectedIds(new Set());
|
|
200
|
+
// return;
|
|
201
|
+
// }
|
|
202
|
+
// // At zoom=1 with identity VPT, getActiveObject() can return null before
|
|
203
|
+
// // Fabric updates _activeObject. Use e.transform as the primary check —
|
|
204
|
+
// // it is populated by Fabric's hit-test regardless of zoom level.
|
|
205
|
+
// const transformTarget = e.transform?.target;
|
|
206
|
+
// const activeObject = canvas.getActiveObject();
|
|
207
|
+
// const activeObjects = canvas.getActiveObjects();
|
|
208
|
+
// const isPartOfActiveSelection =
|
|
209
|
+
// transformTarget === target || // most reliable — direct from event
|
|
210
|
+
// activeObject === target || // selection box group
|
|
211
|
+
// activeObjects.includes(target); // individual object in multi-select
|
|
212
|
+
// if (!isPartOfActiveSelection) {
|
|
213
|
+
// setSelectedIds(new Set());
|
|
214
|
+
// }
|
|
215
|
+
// };
|
|
216
|
+
// const handleSelectionCleared = () => {
|
|
217
|
+
// setSelectedIds(new Set());
|
|
218
|
+
// };
|
|
219
|
+
// canvas.on("object:moving", handleObjectMoving);
|
|
220
|
+
// canvas.on("mouse:down", handleMouseDown);
|
|
221
|
+
// canvas.on("selection:cleared", handleSelectionCleared);
|
|
222
|
+
// return () => {
|
|
223
|
+
// canvas.off("object:moving", handleObjectMoving);
|
|
224
|
+
// canvas.off("mouse:down", handleMouseDown);
|
|
225
|
+
// canvas.off("selection:cleared", handleSelectionCleared);
|
|
226
|
+
// if (fabricMoveRafRef.current !== null) {
|
|
227
|
+
// cancelAnimationFrame(fabricMoveRafRef.current);
|
|
228
|
+
// }
|
|
229
|
+
// };
|
|
230
|
+
// }, [fabricCanvas, canvasReadyProp]); // Issue 5: removed canvasZoom
|
|
231
|
+
// // ── Helpers ─────────────────────────────────────────────────────────────────
|
|
232
|
+
// const getItemPosition = (
|
|
233
|
+
// id: string
|
|
234
|
+
// ): { x: number; y: number } | undefined => {
|
|
235
|
+
// const task = localTasksRef.current.find((t) => t.id === id);
|
|
236
|
+
// if (task) return { x: task.x, y: task.y };
|
|
237
|
+
// const doc = localDocumentsRef.current.find((d) => d.id === id);
|
|
238
|
+
// if (doc) return { x: doc.x, y: doc.y };
|
|
239
|
+
// return undefined;
|
|
240
|
+
// };
|
|
241
|
+
// const isItemInSelectionBox = (
|
|
242
|
+
// x: number,
|
|
243
|
+
// y: number,
|
|
244
|
+
// width: number,
|
|
245
|
+
// height: number,
|
|
246
|
+
// box: { x1: number; y1: number; x2: number; y2: number }
|
|
247
|
+
// ) => {
|
|
248
|
+
// const itemX1 = x * canvasZoom + canvasViewport.x;
|
|
249
|
+
// const itemY1 = y * canvasZoom + canvasViewport.y;
|
|
250
|
+
// const itemX2 = itemX1 + width * canvasZoom;
|
|
251
|
+
// const itemY2 = itemY1 + height * canvasZoom;
|
|
252
|
+
// const boxX1 = Math.min(box.x1, box.x2);
|
|
253
|
+
// const boxY1 = Math.min(box.y1, box.y2);
|
|
254
|
+
// const boxX2 = Math.max(box.x1, box.x2);
|
|
255
|
+
// const boxY2 = Math.max(box.y1, box.y2);
|
|
256
|
+
// return !(boxX2 < itemX1 || boxX1 > itemX2 || boxY2 < itemY1 || boxY1 > itemY2);
|
|
257
|
+
// };
|
|
258
|
+
// // ── Selection box detection ──────────────────────────────────────────────────
|
|
259
|
+
// useEffect(() => {
|
|
260
|
+
// if (!selectionBox) return;
|
|
261
|
+
// // ── O(n) single pass — no sort, no join, no extra allocations ──
|
|
262
|
+
// const newSelected = new Set<string>();
|
|
263
|
+
// for (const task of localTasksRef.current) {
|
|
264
|
+
// if (isItemInSelectionBox(task.x, task.y, 300, 140, selectionBox))
|
|
265
|
+
// newSelected.add(task.id);
|
|
266
|
+
// }
|
|
267
|
+
// for (const doc of localDocumentsRef.current) {
|
|
268
|
+
// if (isItemInSelectionBox(doc.x, doc.y, 320, 160, selectionBox))
|
|
269
|
+
// newSelected.add(doc.id);
|
|
270
|
+
// }
|
|
271
|
+
// // ── O(n) equality check: size first (fast path), then membership ──
|
|
272
|
+
// setSelectedIds((prev) => {
|
|
273
|
+
// if (prev.size !== newSelected.size) return newSelected;
|
|
274
|
+
// for (const id of newSelected) {
|
|
275
|
+
// if (!prev.has(id)) return newSelected; // found a difference, swap
|
|
276
|
+
// }
|
|
277
|
+
// return prev; // identical — return same reference, no re-render
|
|
278
|
+
// });
|
|
279
|
+
// }, [selectionBox, localTasks, localDocuments, canvasZoom, canvasViewport]);
|
|
280
|
+
// // ── Drag start (HTML Node side) ──────────────────────────────────────────────
|
|
281
|
+
// // Helper to extract coordinates regardless of event type
|
|
282
|
+
// const getPointerEvent = (
|
|
283
|
+
// e: React.MouseEvent | React.TouchEvent | MouseEvent | TouchEvent
|
|
284
|
+
// ) => {
|
|
285
|
+
// if ("touches" in e && e.touches.length > 0) return e.touches[0];
|
|
286
|
+
// return e as { clientX: number; clientY: number };
|
|
287
|
+
// };
|
|
288
|
+
// const handleDragStart = (
|
|
289
|
+
// itemId: string,
|
|
290
|
+
// e: React.MouseEvent | React.TouchEvent
|
|
291
|
+
// ) => {
|
|
292
|
+
// // 1. Safety check for the Fabric instance
|
|
293
|
+
// const canvas = fabricCanvas?.current;
|
|
294
|
+
// if (!canvas) return;
|
|
295
|
+
// // 2. Normalize the event (Touch vs Mouse)
|
|
296
|
+
// if (e.cancelable) e.preventDefault();
|
|
297
|
+
// const pointer = getPointerEvent(e);
|
|
298
|
+
// // 3. Determine which items are being dragged
|
|
299
|
+
// // selection update DOES NOT trigger before drag snapshot
|
|
300
|
+
// let itemsToDrag: string[];
|
|
301
|
+
// if (selectedIdsRef.current.has(itemId)) {
|
|
302
|
+
// itemsToDrag = Array.from(selectedIdsRef.current);
|
|
303
|
+
// } else {
|
|
304
|
+
// itemsToDrag = [itemId];
|
|
305
|
+
// }
|
|
306
|
+
// // 4. Capture current World Transform (Zoom & Pan)
|
|
307
|
+
// // We read directly from the canvas to ensure zero-frame lag
|
|
308
|
+
// const vpt = canvas.viewportTransform || [1, 0, 0, 1, 0, 0];
|
|
309
|
+
// const liveZoom = vpt[0];
|
|
310
|
+
// const liveVpX = vpt[4];
|
|
311
|
+
// const liveVpY = vpt[5];
|
|
312
|
+
// // 5. Convert the Click Position from Screen Pixels to World Units
|
|
313
|
+
// const clickWorldX = (pointer.clientX - liveVpX) / liveZoom;
|
|
314
|
+
// const clickWorldY = (pointer.clientY - liveVpY) / liveZoom;
|
|
315
|
+
// // 6. Get the clicked item's current World Position
|
|
316
|
+
// const clickedPos = getItemPosition(itemId);
|
|
317
|
+
// if (!clickedPos) return;
|
|
318
|
+
// // 7. Calculate the Offset in WORLD UNITS
|
|
319
|
+
// // This is the distance from the mouse to the node's top-left in the infinite grid.
|
|
320
|
+
// // This value remains constant even if you zoom during the drag.
|
|
321
|
+
// const worldOffsetX = clickWorldX - clickedPos.x;
|
|
322
|
+
// const worldOffsetY = clickWorldY - clickedPos.y;
|
|
323
|
+
// // 8. Snapshot starting positions for all selected HTML nodes
|
|
324
|
+
// const startPositions = new Map<string, { x: number; y: number }>();
|
|
325
|
+
// itemsToDrag.forEach((id) => {
|
|
326
|
+
// const pos = getItemPosition(id);
|
|
327
|
+
// if (pos) startPositions.set(id, pos);
|
|
328
|
+
// });
|
|
329
|
+
// // 9. Snapshot starting positions for all selected Fabric objects
|
|
330
|
+
// const canvasObjectsStartPos = new Map<
|
|
331
|
+
// FabricObject,
|
|
332
|
+
// { left: number; top: number }
|
|
333
|
+
// >();
|
|
334
|
+
// selectedCanvasObjects.forEach((obj) => {
|
|
335
|
+
// canvasObjectsStartPos.set(obj, {
|
|
336
|
+
// left: obj.left || 0,
|
|
337
|
+
// top: obj.top || 0,
|
|
338
|
+
// });
|
|
339
|
+
// });
|
|
340
|
+
// // 10. Commit to the ref for the requestAnimationFrame loop
|
|
341
|
+
// dragStateRef.current = {
|
|
342
|
+
// isDragging: true,
|
|
343
|
+
// itemIds: itemsToDrag,
|
|
344
|
+
// startPositions,
|
|
345
|
+
// canvasObjectsStartPos,
|
|
346
|
+
// offsetX: clickWorldX, // Now stored as World Units
|
|
347
|
+
// offsetY: clickWorldY, // Now stored as World Units
|
|
348
|
+
// };
|
|
349
|
+
// if (!selectedIdsRef.current.has(itemId) && dragStateRef.current.itemIds.length === 0) {
|
|
350
|
+
// setSelectedIds(new Set([itemId]));
|
|
351
|
+
// }
|
|
352
|
+
// // 11. Trigger UI states
|
|
353
|
+
// setDragging({ itemIds: itemsToDrag });
|
|
354
|
+
// document.body.style.cursor = "grabbing";
|
|
355
|
+
// document.body.style.userSelect = "none";
|
|
356
|
+
// document.body.style.touchAction = "none";
|
|
357
|
+
// };
|
|
358
|
+
// // ── Drag move (HTML Node side) ───────────────────────────────────────────────
|
|
359
|
+
// // Issue 3: Remove localTasks/localDocuments from deps — use refs instead
|
|
360
|
+
// useEffect(() => {
|
|
361
|
+
// if (!dragging) return;
|
|
362
|
+
// const handleMove = (e: MouseEvent | TouchEvent) => {
|
|
363
|
+
// if (!dragStateRef.current.isDragging) return;
|
|
364
|
+
// if (e.cancelable) e.preventDefault();
|
|
365
|
+
// const pointer = getPointerEvent(e);
|
|
366
|
+
// // 1. Throttle updates using requestAnimationFrame for 120Hz/144Hz screen support
|
|
367
|
+
// if (rafIdRef.current !== null) cancelAnimationFrame(rafIdRef.current);
|
|
368
|
+
// rafIdRef.current = requestAnimationFrame(() => {
|
|
369
|
+
// const {
|
|
370
|
+
// itemIds,
|
|
371
|
+
// startPositions,
|
|
372
|
+
// canvasObjectsStartPos,
|
|
373
|
+
// offsetX,
|
|
374
|
+
// offsetY,
|
|
375
|
+
// } = dragStateRef.current;
|
|
376
|
+
// const canvas = fabricCanvas?.current;
|
|
377
|
+
// if (!canvas) return;
|
|
378
|
+
// // 2. Read the "Source of Truth" transform from the canvas
|
|
379
|
+
// const vpt = canvas.viewportTransform!;
|
|
380
|
+
// const liveZoom = vpt[0]; // Scale
|
|
381
|
+
// const liveVpX = vpt[4]; // Pan X
|
|
382
|
+
// const liveVpY = vpt[5]; // Pan Y
|
|
383
|
+
// // 3. Convert current Mouse Screen Position → World Position
|
|
384
|
+
// const currentWorldX = (pointer.clientX - liveVpX) / liveZoom;
|
|
385
|
+
// const currentWorldY = (pointer.clientY - liveVpY) / liveZoom;
|
|
386
|
+
// // 4. Calculate where the "Anchor" node should be in World Units
|
|
387
|
+
// // (Current Mouse World - Initial World Offset from Start)
|
|
388
|
+
// const deltaX = currentWorldX - offsetX;
|
|
389
|
+
// const deltaY = currentWorldY - offsetY;
|
|
390
|
+
// // 5. Calculate the Movement Delta in World Units
|
|
391
|
+
// // We compare where the first item started vs where it is now.
|
|
392
|
+
// const firstId = itemIds[0];
|
|
393
|
+
// const firstStart = startPositions.get(firstId);
|
|
394
|
+
// if (!firstStart) return;
|
|
395
|
+
// // 6. Update HTML Nodes (Batching these into one state update)
|
|
396
|
+
// setLocalTasks((prev) =>
|
|
397
|
+
// prev.map((t) =>
|
|
398
|
+
// itemIds.includes(t.id)
|
|
399
|
+
// ? {
|
|
400
|
+
// ...t,
|
|
401
|
+
// x: (startPositions.get(t.id)?.x ?? t.x) + deltaX,
|
|
402
|
+
// y: (startPositions.get(t.id)?.y ?? t.y) + deltaY,
|
|
403
|
+
// }
|
|
404
|
+
// : t
|
|
405
|
+
// )
|
|
406
|
+
// );
|
|
407
|
+
// setLocalDocuments((prev) =>
|
|
408
|
+
// prev.map((d) =>
|
|
409
|
+
// itemIds.includes(d.id)
|
|
410
|
+
// ? {
|
|
411
|
+
// ...d,
|
|
412
|
+
// x: (startPositions.get(d.id)?.x ?? d.x) + deltaX,
|
|
413
|
+
// y: (startPositions.get(d.id)?.y ?? d.y) + deltaY,
|
|
414
|
+
// }
|
|
415
|
+
// : d
|
|
416
|
+
// )
|
|
417
|
+
// );
|
|
418
|
+
// // 7. Sync Fabric Objects (Imperative update for performance)
|
|
419
|
+
// canvasObjectsStartPos.forEach((startPos, obj) => {
|
|
420
|
+
// obj.set({
|
|
421
|
+
// left: startPos.left + deltaX,
|
|
422
|
+
// top: startPos.top + deltaY,
|
|
423
|
+
// });
|
|
424
|
+
// obj.setCoords(); // Required for selection/intersection accuracy
|
|
425
|
+
// });
|
|
426
|
+
// // 8. Single render call for all Fabric changes
|
|
427
|
+
// canvas.requestRenderAll();
|
|
428
|
+
// });
|
|
429
|
+
// };
|
|
430
|
+
// // Issue 4: Use refs for always-current values
|
|
431
|
+
// const handleEnd = () => {
|
|
432
|
+
// if (rafIdRef.current !== null) cancelAnimationFrame(rafIdRef.current);
|
|
433
|
+
// dragStateRef.current.isDragging = false;
|
|
434
|
+
// setDragging(null);
|
|
435
|
+
// document.body.style.cursor = "";
|
|
436
|
+
// document.body.style.userSelect = "";
|
|
437
|
+
// document.body.style.touchAction = "";
|
|
438
|
+
// onTasksUpdate?.(localTasksRef.current);
|
|
439
|
+
// onDocumentsUpdate?.(localDocumentsRef.current);
|
|
440
|
+
// };
|
|
441
|
+
// window.addEventListener("mousemove", handleMove, { passive: false });
|
|
442
|
+
// window.addEventListener("mouseup", handleEnd);
|
|
443
|
+
// window.addEventListener("touchmove", handleMove, { passive: false });
|
|
444
|
+
// window.addEventListener("touchend", handleEnd);
|
|
445
|
+
// window.addEventListener("touchcancel", handleEnd);
|
|
446
|
+
// return () => {
|
|
447
|
+
// window.removeEventListener("mousemove", handleMove);
|
|
448
|
+
// window.removeEventListener("mouseup", handleEnd);
|
|
449
|
+
// window.removeEventListener("touchmove", handleMove);
|
|
450
|
+
// window.removeEventListener("touchend", handleEnd);
|
|
451
|
+
// window.removeEventListener("touchcancel", handleEnd);
|
|
452
|
+
// };
|
|
453
|
+
// }, [dragging, fabricCanvas]); // Issue 3: removed localTasks/localDocuments
|
|
454
|
+
// // ── Selection, Status, Keyboard Logic ────────────────────────────────────────
|
|
455
|
+
// const handleSelect = (id: string, e?: React.MouseEvent) => {
|
|
456
|
+
// if (e?.shiftKey || e?.ctrlKey || e?.metaKey) {
|
|
457
|
+
// setSelectedIds((prev) => {
|
|
458
|
+
// const next = new Set(prev);
|
|
459
|
+
// next.has(id) ? next.delete(id) : next.add(id);
|
|
460
|
+
// return next;
|
|
461
|
+
// });
|
|
462
|
+
// } else {
|
|
463
|
+
// setSelectedIds(new Set([id]));
|
|
464
|
+
// }
|
|
465
|
+
// };
|
|
466
|
+
// const handleStatusChange = (
|
|
467
|
+
// taskId: string,
|
|
468
|
+
// newStatus: "todo" | "in-progress" | "done"
|
|
469
|
+
// ) => {
|
|
470
|
+
// const updated = localTasksRef.current.map((t) =>
|
|
471
|
+
// t.id === taskId ? { ...t, status: newStatus } : t
|
|
472
|
+
// );
|
|
473
|
+
// setLocalTasks(updated);
|
|
474
|
+
// onTasksUpdate?.(updated);
|
|
475
|
+
// };
|
|
476
|
+
// // Issue 9: Use refs and only depend on stable callbacks
|
|
477
|
+
// useEffect(() => {
|
|
478
|
+
// const handleKeyDown = (e: KeyboardEvent) => {
|
|
479
|
+
// // Don't trigger if typing in input
|
|
480
|
+
// if (
|
|
481
|
+
// e.target instanceof HTMLInputElement ||
|
|
482
|
+
// e.target instanceof HTMLTextAreaElement
|
|
483
|
+
// )
|
|
484
|
+
// return;
|
|
485
|
+
// // Select All
|
|
486
|
+
// if ((e.ctrlKey || e.metaKey) && e.key === "a") {
|
|
487
|
+
// e.preventDefault();
|
|
488
|
+
// setSelectedIds(
|
|
489
|
+
// new Set([
|
|
490
|
+
// ...localTasksRef.current.map((t) => t.id),
|
|
491
|
+
// ...localDocumentsRef.current.map((d) => d.id),
|
|
492
|
+
// ])
|
|
493
|
+
// );
|
|
494
|
+
// }
|
|
495
|
+
// // Clear selection
|
|
496
|
+
// if (e.key === "Escape") {
|
|
497
|
+
// setSelectedIds(new Set());
|
|
498
|
+
// }
|
|
499
|
+
// // Delete selected nodes
|
|
500
|
+
// if (
|
|
501
|
+
// (e.key === "Delete" || e.key === "Backspace") &&
|
|
502
|
+
// selectedIdsRef.current.size > 0
|
|
503
|
+
// ) {
|
|
504
|
+
// e.preventDefault();
|
|
505
|
+
// const sel = selectedIdsRef.current;
|
|
506
|
+
// const updatedTasks = localTasksRef.current.filter((t) => !sel.has(t.id));
|
|
507
|
+
// const updatedDocs = localDocumentsRef.current.filter((d) => !sel.has(d.id));
|
|
508
|
+
// setLocalTasks(updatedTasks);
|
|
509
|
+
// setLocalDocuments(updatedDocs);
|
|
510
|
+
// setSelectedIds(new Set());
|
|
511
|
+
// onTasksUpdate?.(updatedTasks);
|
|
512
|
+
// onDocumentsUpdate?.(updatedDocs);
|
|
513
|
+
// }
|
|
514
|
+
// };
|
|
515
|
+
// window.addEventListener("keydown", handleKeyDown);
|
|
516
|
+
// return () => window.removeEventListener("keydown", handleKeyDown);
|
|
517
|
+
// }, [onTasksUpdate, onDocumentsUpdate]); // Issue 9: only stable callbacks
|
|
518
|
+
// // ── Render helper ────────────────────────────────────────────────────────────
|
|
519
|
+
// const renderItem = (
|
|
520
|
+
// id: string,
|
|
521
|
+
// x: number,
|
|
522
|
+
// y: number,
|
|
523
|
+
// children: React.ReactNode
|
|
524
|
+
// ) => {
|
|
525
|
+
// const screenX = x * canvasZoom;
|
|
526
|
+
// const screenY = y * canvasZoom;
|
|
527
|
+
// // 1. Detect if the user is interacting with the canvas at all
|
|
528
|
+
// const isDragging = dragging?.itemIds.includes(id);
|
|
529
|
+
// return (
|
|
530
|
+
// <div
|
|
531
|
+
// key={id}
|
|
532
|
+
// className="pointer-events-auto absolute"
|
|
533
|
+
// style={{
|
|
534
|
+
// left: 0,
|
|
535
|
+
// top: 0,
|
|
536
|
+
// // 2. Use translate3d for GPU performance
|
|
537
|
+
// transform: `translate3d(${x}px, ${y}px, 0) scale(${canvasZoom})`,
|
|
538
|
+
// transformOrigin: "top left",
|
|
539
|
+
// // 3. THE FIX: Remove transition entirely during any viewport change
|
|
540
|
+
// // Any 'ease' during zoom causes the "shaking" behavior.
|
|
541
|
+
// transition: "none",
|
|
542
|
+
// // 4. Optimization
|
|
543
|
+
// willChange: "transform",
|
|
544
|
+
// zIndex: isDragging ? 1000 : 1,
|
|
545
|
+
// }}
|
|
546
|
+
// >
|
|
547
|
+
// {children}
|
|
548
|
+
// </div>
|
|
549
|
+
// );
|
|
550
|
+
// };
|
|
551
|
+
// return (
|
|
552
|
+
// <div
|
|
553
|
+
// ref={overlayRef}
|
|
554
|
+
// className="absolute inset-0 pointer-events-none"
|
|
555
|
+
// style={{ zIndex: 50 }}
|
|
556
|
+
// onWheel={handleOverlayWheel}
|
|
557
|
+
// onClick={(e) => {
|
|
558
|
+
// if (e.target === e.currentTarget) setSelectedIds(new Set());
|
|
559
|
+
// }}
|
|
560
|
+
// >
|
|
561
|
+
// <div
|
|
562
|
+
// className="absolute top-0 left-0 pointer-events-none"
|
|
563
|
+
// style={{
|
|
564
|
+
// transform: `translate(${canvasViewport.x}px, ${canvasViewport.y}px)`,
|
|
565
|
+
// transformOrigin: "top left",
|
|
566
|
+
// }}
|
|
567
|
+
// >
|
|
568
|
+
// {localTasks.map((task) =>
|
|
569
|
+
// renderItem(
|
|
570
|
+
// task.id,
|
|
571
|
+
// task.x,
|
|
572
|
+
// task.y,
|
|
573
|
+
// <TaskNode
|
|
574
|
+
// {...task}
|
|
575
|
+
// isSelected={selectedIds.has(task.id)}
|
|
576
|
+
// onSelect={handleSelect}
|
|
577
|
+
// onDragStart={handleDragStart}
|
|
578
|
+
// onStatusChange={handleStatusChange}
|
|
579
|
+
// zoom={1}
|
|
580
|
+
// />
|
|
581
|
+
// )
|
|
582
|
+
// )}
|
|
583
|
+
// {localDocuments.map((doc) =>
|
|
584
|
+
// renderItem(
|
|
585
|
+
// doc.id,
|
|
586
|
+
// doc.x,
|
|
587
|
+
// doc.y,
|
|
588
|
+
// <DocumentNode
|
|
589
|
+
// {...doc}
|
|
590
|
+
// isSelected={selectedIds.has(doc.id)}
|
|
591
|
+
// onSelect={handleSelect}
|
|
592
|
+
// onDragStart={handleDragStart}
|
|
593
|
+
// />
|
|
594
|
+
// )
|
|
595
|
+
// )}
|
|
596
|
+
// </div>
|
|
597
|
+
// </div>
|
|
598
|
+
// );
|
|
599
|
+
// }, (prev, next) => {
|
|
600
|
+
// // Custom comparator — skip re-render if props are equal
|
|
601
|
+
// // Return true to skip re-render, false to re-render
|
|
602
|
+
// return (
|
|
603
|
+
// prev.tasks === next.tasks &&
|
|
604
|
+
// prev.documents === next.documents &&
|
|
605
|
+
// prev.canvasZoom === next.canvasZoom &&
|
|
606
|
+
// prev.canvasViewport?.x === next.canvasViewport?.x &&
|
|
607
|
+
// prev.canvasViewport?.y === next.canvasViewport?.y &&
|
|
608
|
+
// prev.selectionBox === next.selectionBox &&
|
|
609
|
+
// prev.selectedCanvasObjects === next.selectedCanvasObjects &&
|
|
610
|
+
// prev.onTasksUpdate === next.onTasksUpdate &&
|
|
611
|
+
// prev.onDocumentsUpdate === next.onDocumentsUpdate &&
|
|
612
|
+
// prev.canvasReady === next.canvasReady
|
|
613
|
+
// // fabricCanvas ref intentionally omitted — it's stable and doesn't need comparison
|
|
614
|
+
// );
|
|
615
|
+
// });
|