(item, monitor, customOptions)
| 513 | getSignerPos(item, monitor, customOptions); |
| 514 | }; |
| 515 | const getSignerPos = (item, monitor, customOptions) => { |
| 516 | if (uniqueId) { |
| 517 | const signer = signersdata.find((x) => x.Id === uniqueId); |
| 518 | const prefillUser = prefillSigner.find((x) => x.Id === uniqueId); |
| 519 | if (signer || prefillUser) { |
| 520 | const posZIndex = zIndex + 1; |
| 521 | setZIndex(posZIndex); |
| 522 | const key = randomId(); |
| 523 | const containerScale = getContainerScale( |
| 524 | pdfOriginalWH, |
| 525 | pageNumber, |
| 526 | containerWH |
| 527 | ); |
| 528 | let dropData = [], |
| 529 | filterSignerPos, |
| 530 | currentPagePosition, |
| 531 | placeHolder, |
| 532 | dropObj; |
| 533 | filterSignerPos = signerPos.find((data) => data.Id === uniqueId); |
| 534 | const dragTypeValue = item?.text ? item.text : monitor.type; |
| 535 | const widgetWidth = |
| 536 | defaultWidthHeight(dragTypeValue).width * containerScale; |
| 537 | const widgetHeight = |
| 538 | defaultWidthHeight(dragTypeValue).height * containerScale; |
| 539 | //adding and updating drop position in array when user drop signature button in div |
| 540 | |
| 541 | // Handle custom position from drawing (OS-1229) |
| 542 | if (customOptions?.customPosition) { |
| 543 | ({ dropObj, placeHolder } = utils.createCustomPositionWidget({ |
| 544 | customPosition: customOptions.customPosition, |
| 545 | key, |
| 546 | containerScale, |
| 547 | posZIndex, |
| 548 | dragTypeValue, |
| 549 | pageNumber, |
| 550 | owner, |
| 551 | signerPlaceHolder: filterSignerPos?.placeHolder, |
| 552 | roleName |
| 553 | })); |
| 554 | dropData = placeHolder.pos; |
| 555 | } else if (item === "onclick") { |
| 556 | // Use the current page container (id="container") so that the |
| 557 | // height reflects one page, not the entire multi-page document. |
| 558 | const containerEl = |
| 559 | document.getElementById("container") || divRef.current; |
| 560 | const divWidth = containerEl.getBoundingClientRect().width; |
| 561 | const divHeight = containerEl.getBoundingClientRect().height; |
| 562 | // Compute the pixel‐space center within the PDF viewport: |
| 563 | const centerX_Pixels = divWidth / 2 - widgetWidth / 2; |
| 564 | const xPosition_Final = centerX_Pixels / (containerScale * scale); |
| 565 | dropObj = { |
| 566 | //onclick put placeholder center on pdf |
| 567 | xPosition: xPosition_Final, |
| 568 | yPosition: |
| 569 | (divHeight / 2 - widgetHeight / 2) / (containerScale * scale), |
| 570 | isStamp: |
| 571 | (dragTypeValue === "stamp" || dragTypeValue === "image") && true, |
| 572 | key: key, |
no test coverage detected