@pixldocs/canvas-renderer 0.5.245 → 0.5.246

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.
@@ -11102,7 +11102,9 @@ const PageCanvas = forwardRef(
11102
11102
  const isSyncingSelectionToFabricRef = useRef(false);
11103
11103
  const suppressGroupMemberBordersRef = useRef([]);
11104
11104
  const editingTextIdRef = useRef(null);
11105
- const pendingTextEditOnUpRef = useRef(null);
11105
+ const selectAllTextOnEditingEnterRef = useRef(null);
11106
+ const suppressedTextEditObjectsRef = useRef([]);
11107
+ const suppressTextDoubleClickUntilRef = useRef(0);
11106
11108
  const syncLockedRef = useRef(false);
11107
11109
  const editLockRef = useRef(false);
11108
11110
  const editLockCountRef = useRef(0);
@@ -11811,6 +11813,44 @@ const PageCanvas = forwardRef(
11811
11813
  });
11812
11814
  fabricCanvas.hoverCursor = "default";
11813
11815
  fabricCanvas.moveCursor = "move";
11816
+ const suppressTextEditForClick = (textbox) => {
11817
+ if (!textbox) return;
11818
+ textbox.selected = false;
11819
+ textbox.__lastSelected = false;
11820
+ textbox.__corner = void 0;
11821
+ textbox.__pixldocsSuppressNextEdit = true;
11822
+ suppressTextDoubleClickUntilRef.current = Date.now() + 350;
11823
+ if (!suppressedTextEditObjectsRef.current.some((entry) => entry.textbox === textbox)) {
11824
+ suppressedTextEditObjectsRef.current.push({ textbox, editable: textbox.editable });
11825
+ }
11826
+ textbox.editable = false;
11827
+ };
11828
+ const restoreSuppressedTextEditObjects = () => {
11829
+ const entries = suppressedTextEditObjectsRef.current.splice(0);
11830
+ for (const { textbox, editable } of entries) {
11831
+ try {
11832
+ textbox.editable = editable;
11833
+ delete textbox.__pixldocsSuppressNextEdit;
11834
+ } catch {
11835
+ }
11836
+ }
11837
+ };
11838
+ const restoreSuppressedTextEditObjectsSoon = () => {
11839
+ requestAnimationFrame(() => {
11840
+ restoreSuppressedTextEditObjects();
11841
+ });
11842
+ };
11843
+ const selectAllActiveTextbox = (textbox) => {
11844
+ var _a2;
11845
+ try {
11846
+ textbox.selectAll();
11847
+ } catch {
11848
+ const len = ((_a2 = textbox.text) == null ? void 0 : _a2.length) ?? 0;
11849
+ textbox.selectionStart = 0;
11850
+ textbox.selectionEnd = len;
11851
+ }
11852
+ fabricCanvas.requestRenderAll();
11853
+ };
11814
11854
  if (!allowSelection) {
11815
11855
  fabricCanvas.selection = false;
11816
11856
  fabricCanvas.on("selection:created", () => {
@@ -12800,6 +12840,7 @@ const PageCanvas = forwardRef(
12800
12840
  fabricCanvas.__updateDrilledGroupOutline = updateDrilledGroupOutline;
12801
12841
  fabricCanvas.on("mouse:down:before", (opt) => {
12802
12842
  var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
12843
+ const activeBeforeMouseDown = fabricCanvas.getActiveObject();
12803
12844
  if (editLockRef.current) {
12804
12845
  const active = fabricCanvas.getActiveObject();
12805
12846
  if (active && (((_a2 = active._ct) == null ? void 0 : _a2.isCropGroup) || active.__cropGroup)) {
@@ -12825,6 +12866,9 @@ const PageCanvas = forwardRef(
12825
12866
  targetId = childId;
12826
12867
  }
12827
12868
  }
12869
+ if (target instanceof fabric.Textbox && targetId && targetId !== "__background__" && activeBeforeMouseDown === target && !target.isEditing && !target.__corner && !isMultiSelectModifier(opt.e)) {
12870
+ selectAllTextOnEditingEnterRef.current = targetId;
12871
+ }
12828
12872
  const activeEditingGroupId = fabricCanvas.__activeEditingGroupId ?? null;
12829
12873
  const pageNow = useEditorStore.getState().canvas.pages.find((p) => p.id === pageId);
12830
12874
  const childrenNow = (pageNow == null ? void 0 : pageNow.children) ?? [];
@@ -12932,9 +12976,13 @@ const PageCanvas = forwardRef(
12932
12976
  opt.target = effectiveTarget;
12933
12977
  pendingGroupPromotionRef.current = null;
12934
12978
  pendingGroupDrillInRef.current = { groupId: drillGroup.id, childId: effectiveTargetId, target: effectiveTarget };
12935
- effectiveTarget.selected = false;
12936
- effectiveTarget.__lastSelected = false;
12937
- effectiveTarget.__corner = void 0;
12979
+ if (effectiveTarget instanceof fabric.Textbox) {
12980
+ suppressTextEditForClick(effectiveTarget);
12981
+ } else {
12982
+ effectiveTarget.selected = false;
12983
+ effectiveTarget.__lastSelected = false;
12984
+ effectiveTarget.__corner = void 0;
12985
+ }
12938
12986
  selectElements([effectiveTargetId], false, false);
12939
12987
  updateDrilledGroupOutline();
12940
12988
  fabricCanvas.requestRenderAll();
@@ -13077,7 +13125,6 @@ const PageCanvas = forwardRef(
13077
13125
  lockEdits();
13078
13126
  }
13079
13127
  const o = fabricCanvas.getActiveObject();
13080
- pendingTextEditOnUpRef.current = null;
13081
13128
  if (!o) return;
13082
13129
  o.__lockScaleDuringCrop = false;
13083
13130
  });
@@ -13104,9 +13151,13 @@ const PageCanvas = forwardRef(
13104
13151
  (_b2 = (_a2 = pendingDrillIn.target).set) == null ? void 0 : _b2.call(_a2, { selectable: true, evented: true, hasBorders: true, hasControls: true });
13105
13152
  fabricCanvas.setActiveObject(pendingDrillIn.target);
13106
13153
  pendingDrillIn.target.setCoords();
13107
- pendingDrillIn.target.selected = false;
13108
- pendingDrillIn.target.__lastSelected = false;
13109
- pendingDrillIn.target.__corner = void 0;
13154
+ if (pendingDrillIn.target instanceof fabric.Textbox) {
13155
+ suppressTextEditForClick(pendingDrillIn.target);
13156
+ } else {
13157
+ pendingDrillIn.target.selected = false;
13158
+ pendingDrillIn.target.__lastSelected = false;
13159
+ pendingDrillIn.target.__corner = void 0;
13160
+ }
13110
13161
  fabricCanvas.requestRenderAll();
13111
13162
  } finally {
13112
13163
  requestAnimationFrame(() => {
@@ -13179,6 +13230,7 @@ const PageCanvas = forwardRef(
13179
13230
  syncLockedRef.current = false;
13180
13231
  }, 0);
13181
13232
  unlockEditsSoon();
13233
+ restoreSuppressedTextEditObjectsSoon();
13182
13234
  if (allowDynamicFieldClick && onDynamicFieldClick && e.target) {
13183
13235
  const clickedId = getObjectId(e.target);
13184
13236
  if (clickedId && dynamicFieldIds.includes(clickedId)) {
@@ -14465,6 +14517,9 @@ const PageCanvas = forwardRef(
14465
14517
  else if (active instanceof fabric.ActiveSelection && active.getObjects().length === 1 && active.getObjects()[0] instanceof fabric.Textbox) target = active.getObjects()[0];
14466
14518
  }
14467
14519
  if (target && target instanceof fabric.Textbox) {
14520
+ if (Date.now() < suppressTextDoubleClickUntilRef.current || target.__pixldocsSuppressNextEdit) {
14521
+ return;
14522
+ }
14468
14523
  const elementId = getObjectId(target);
14469
14524
  if (target.__formattingEnabled === true || target.editable === false) {
14470
14525
  toast.info("Inline formatting is on — edit the text in the right panel.", {
@@ -14481,7 +14536,21 @@ const PageCanvas = forwardRef(
14481
14536
  const target = e.target;
14482
14537
  if (target && target instanceof fabric.Textbox) {
14483
14538
  const elementId = getObjectId(target);
14539
+ if (target.__pixldocsSuppressNextEdit) {
14540
+ try {
14541
+ target.exitEditing();
14542
+ } catch {
14543
+ }
14544
+ editingTextIdRef.current = null;
14545
+ setEditingText(false);
14546
+ fabricCanvas.requestRenderAll();
14547
+ return;
14548
+ }
14484
14549
  editingTextIdRef.current = elementId || null;
14550
+ if (elementId && selectAllTextOnEditingEnterRef.current === elementId) {
14551
+ selectAllTextOnEditingEnterRef.current = null;
14552
+ selectAllActiveTextbox(target);
14553
+ }
14485
14554
  setEditingText(true);
14486
14555
  }
14487
14556
  });
@@ -23376,9 +23445,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
23376
23445
  }
23377
23446
  return svgString;
23378
23447
  }
23379
- const resolvedPackageVersion = "0.5.245";
23448
+ const resolvedPackageVersion = "0.5.246";
23380
23449
  const PACKAGE_VERSION = resolvedPackageVersion;
23381
- const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.245";
23450
+ const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.246";
23382
23451
  const roundParityValue = (value) => {
23383
23452
  if (typeof value !== "number") return value;
23384
23453
  return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
@@ -24192,7 +24261,7 @@ class PixldocsRenderer {
24192
24261
  await this.waitForCanvasScene(container, cloned, i);
24193
24262
  }
24194
24263
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
24195
- const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-qzZ0kZCI.js");
24264
+ const { exportMultiPagePdf, preparePagesForExport } = await import("./vectorPdfExport-D91zbb8z.js");
24196
24265
  const prepared = preparePagesForExport(
24197
24266
  cloned.pages,
24198
24267
  canvasWidth,
@@ -26512,7 +26581,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
26512
26581
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
26513
26582
  sanitizeSvgTreeForPdf(svgToDraw);
26514
26583
  try {
26515
- const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-qzZ0kZCI.js");
26584
+ const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await import("./vectorPdfExport-D91zbb8z.js");
26516
26585
  try {
26517
26586
  await logTextMeasurementDiagnostic(svgToDraw);
26518
26587
  } catch {
@@ -26912,4 +26981,4 @@ export {
26912
26981
  buildTeaserBlurFlatKeys as y,
26913
26982
  collectFontDescriptorsFromConfig as z
26914
26983
  };
26915
- //# sourceMappingURL=index-FE8QLDiA.js.map
26984
+ //# sourceMappingURL=index-krO2Qm7P.js.map