(item, monitor, customOptions)
| 450 | }; |
| 451 | // `getSignerPos` is used to get placeholder position when user place it and save it in array |
| 452 | const getSignerPos = (item, monitor, customOptions) => { |
| 453 | if (uniqueId) { |
| 454 | const signer = signersdata.find((x) => x.Id === uniqueId); |
| 455 | const prefillUser = prefillSigner.find((x) => x.Id === uniqueId); |
| 456 | if (signer || prefillUser) { |
| 457 | const posZIndex = zIndex + 1; |
| 458 | setZIndex(posZIndex); |
| 459 | const containerScale = getContainerScale( |
| 460 | pdfOriginalWH, |
| 461 | pageNumber, |
| 462 | containerWH |
| 463 | ); |
| 464 | const key = randomId(); |
| 465 | const dragTypeValue = item?.text ? item.text : monitor.type; |
| 466 | const widgetWidth = |
| 467 | defaultWidthHeight(dragTypeValue).width * containerScale; |
| 468 | const widgetHeight = |
| 469 | defaultWidthHeight(dragTypeValue).height * containerScale; |
| 470 | let dropData = [], |
| 471 | dropObj, |
| 472 | currentPagePosition, |
| 473 | filterSignerPos, |
| 474 | placeHolder; |
| 475 | filterSignerPos = signerPos.find((data) => data.Id === uniqueId); |
| 476 | |
| 477 | // Handle custom position from drawing (OS-1229) |
| 478 | if (customOptions?.customPosition) { |
| 479 | ({ dropObj, placeHolder } = utils.createCustomPositionWidget({ |
| 480 | customPosition: customOptions.customPosition, |
| 481 | key, |
| 482 | containerScale, |
| 483 | posZIndex, |
| 484 | dragTypeValue, |
| 485 | pageNumber, |
| 486 | owner, |
| 487 | signerPlaceHolder: filterSignerPos?.placeHolder, |
| 488 | roleName |
| 489 | })); |
| 490 | dropData = placeHolder.pos; |
| 491 | } else if (item === "onclick") { |
| 492 | // Use the current page container (id="container") so that the |
| 493 | // height reflects one page, not the entire multi-page document. |
| 494 | const containerEl = |
| 495 | document.getElementById("container") || divRef.current; |
| 496 | const divWidth = containerEl.getBoundingClientRect().width; |
| 497 | const divHeight = containerEl.getBoundingClientRect().height; |
| 498 | // Compute the pixel‐space center within the PDF viewport: |
| 499 | const centerX_Pixels = divWidth / 2 - widgetWidth / 2; |
| 500 | const xPosition_Final = centerX_Pixels / (containerScale * scale); |
| 501 | dropObj = { |
| 502 | //onclick put placeholder center on pdf |
| 503 | xPosition: xPosition_Final, |
| 504 | yPosition: |
| 505 | (divHeight / 2 - widgetHeight / 2) / (containerScale * scale), |
| 506 | isStamp: |
| 507 | (dragTypeValue === "stamp" || dragTypeValue === "image") && true, |
| 508 | key: key, |
| 509 | scale: containerScale, |
no test coverage detected