@mhamz.01/easyflow-whiteboard 2.65.0 → 2.67.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.
@@ -1 +1 @@
1
- {"version":3,"file":"custom-node-overlay-layer.d.ts","sourceRoot":"","sources":["../../../src/components/node/custom-node-overlay-layer.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAS9C,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,MAAM,CAAC;IACxC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,UAAU,uBAAuB;IAC/B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACxC,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,YAAY,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACzE,qBAAqB,CAAC,EAAE,YAAY,EAAE,CAAC;IACvC,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAaD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,KAAK,EACL,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,UAAc,EACd,cAA+B,EAC/B,YAAmB,EACnB,qBAA0B,EAC1B,YAAY,GACb,EAAE,uBAAuB,2CA2kBzB"}
1
+ {"version":3,"file":"custom-node-overlay-layer.d.ts","sourceRoot":"","sources":["../../../src/components/node/custom-node-overlay-layer.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAS9C,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,MAAM,CAAC;IACxC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,UAAU,uBAAuB;IAC/B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACxC,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,YAAY,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACzE,qBAAqB,CAAC,EAAE,YAAY,EAAE,CAAC;IACvC,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAaD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,KAAK,EACL,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,UAAc,EACd,cAA+B,EAC/B,YAAmB,EACnB,qBAA0B,EAC1B,YAAY,GACb,EAAE,uBAAuB,2CAujBzB"}
@@ -220,70 +220,53 @@ export default function CanvasOverlayLayer({ tasks, documents, onTasksUpdate, on
220
220
  return e;
221
221
  };
222
222
  const handleDragStart = (itemId, e) => {
223
- // 1. Safety check for the Fabric instance
224
223
  const canvas = fabricCanvas?.current;
225
224
  if (!canvas)
226
225
  return;
227
- // 2. Normalize the event (Touch vs Mouse)
228
226
  if (e.cancelable)
229
227
  e.preventDefault();
230
228
  const pointer = getPointerEvent(e);
231
- // 3. Determine which items are being dragged
232
- // selection update DOES NOT trigger before drag snapshot
233
229
  let itemsToDrag;
234
230
  if (selectedIds.has(itemId)) {
235
231
  itemsToDrag = Array.from(selectedIds);
236
232
  }
237
233
  else {
238
234
  itemsToDrag = [itemId];
235
+ setSelectedIds(new Set([itemId]));
239
236
  }
240
- // 4. Capture current World Transform (Zoom & Pan)
241
- // We read directly from the canvas to ensure zero-frame lag
242
237
  const vpt = canvas.viewportTransform || [1, 0, 0, 1, 0, 0];
243
238
  const liveZoom = vpt[0];
244
239
  const liveVpX = vpt[4];
245
240
  const liveVpY = vpt[5];
246
- // 5. Convert the Click Position from Screen Pixels to World Units
247
241
  const clickWorldX = (pointer.clientX - liveVpX) / liveZoom;
248
242
  const clickWorldY = (pointer.clientY - liveVpY) / liveZoom;
249
- // 6. Get the clicked item's current World Position
250
243
  const clickedPos = getItemPosition(itemId);
251
244
  if (!clickedPos)
252
245
  return;
253
- // 7. Calculate the Offset in WORLD UNITS
254
- // This is the distance from the mouse to the node's top-left in the infinite grid.
255
- // This value remains constant even if you zoom during the drag.
256
246
  const worldOffsetX = clickWorldX - clickedPos.x;
257
247
  const worldOffsetY = clickWorldY - clickedPos.y;
258
- // 8. Snapshot starting positions for all selected HTML nodes
259
248
  const startPositions = new Map();
260
249
  itemsToDrag.forEach((id) => {
261
250
  const pos = getItemPosition(id);
262
251
  if (pos)
263
252
  startPositions.set(id, pos);
264
253
  });
265
- // 9. Snapshot starting positions for all selected Fabric objects
266
254
  const canvasObjectsStartPos = new Map();
267
255
  selectedCanvasObjects.forEach((obj) => {
268
256
  canvasObjectsStartPos.set(obj, { left: obj.left || 0, top: obj.top || 0 });
269
257
  });
270
- // 10. Commit to the ref for the requestAnimationFrame loop
271
258
  dragStateRef.current = {
272
259
  isDragging: true,
273
260
  itemIds: itemsToDrag,
274
261
  startPositions,
275
262
  canvasObjectsStartPos,
276
- offsetX: worldOffsetX, // Now stored as World Units
277
- offsetY: worldOffsetY, // Now stored as World Units
263
+ offsetX: worldOffsetX,
264
+ offsetY: worldOffsetY,
278
265
  };
279
- if (!selectedIds.has(itemId) && dragStateRef.current.itemIds.length === 0) {
280
- setSelectedIds(new Set([itemId]));
281
- }
282
- // 11. Trigger UI states
283
266
  setDragging({ itemIds: itemsToDrag });
267
+ // ── ATTACH LISTENERS DIRECTLY ──
284
268
  document.body.style.cursor = "grabbing";
285
269
  document.body.style.userSelect = "none";
286
- document.body.style.touchAction = "none";
287
270
  };
288
271
  // ── Drag move (HTML Node side) ───────────────────────────────────────────────
289
272
  useEffect(() => {
@@ -348,24 +331,20 @@ export default function CanvasOverlayLayer({ tasks, documents, onTasksUpdate, on
348
331
  });
349
332
  };
350
333
  const handleEnd = () => {
351
- if (rafIdRef.current !== null) {
334
+ if (rafIdRef.current !== null)
352
335
  cancelAnimationFrame(rafIdRef.current);
353
- rafIdRef.current = null;
354
- }
336
+ // 1. Kill the flag first
355
337
  dragStateRef.current.isDragging = false;
356
338
  setDragging(null);
339
+ // 2. Remove the listeners immediately
340
+ window.removeEventListener("mousemove", handleMove);
341
+ window.removeEventListener("mouseup", handleEnd);
342
+ window.removeEventListener("touchmove", handleMove);
343
+ window.removeEventListener("touchend", handleEnd);
357
344
  document.body.style.cursor = "";
358
345
  document.body.style.userSelect = "";
359
- document.body.style.touchAction = "";
360
- // Read latest state via functional updater — never stale
361
- setLocalTasks((latest) => {
362
- onTasksUpdate?.(latest);
363
- return latest;
364
- });
365
- setLocalDocuments((latest) => {
366
- onDocumentsUpdate?.(latest);
367
- return latest;
368
- });
346
+ onTasksUpdate?.(localTasks);
347
+ onDocumentsUpdate?.(localDocuments);
369
348
  };
370
349
  window.addEventListener("mousemove", handleMove, { passive: false });
371
350
  window.addEventListener("mouseup", handleEnd);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mhamz.01/easyflow-whiteboard",
3
- "version": "2.65.0",
3
+ "version": "2.67.0",
4
4
  "description": "A feature-rich whiteboard component built with Fabric.js and React",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",