(item, monitor)
| 347 | }; |
| 348 | //function for setting position after drop signature button over pdf |
| 349 | const addPositionOfSignature = (item, monitor) => { |
| 350 | setCurrWidgetsDetails({}); |
| 351 | const key = randomId(); |
| 352 | let dropData = []; |
| 353 | let dropObj = {}; |
| 354 | let filterDropPos = xyPosition?.filter( |
| 355 | (data) => data.pageNumber === pageNumber |
| 356 | ); |
| 357 | const dragTypeValue = item?.text ? item.text : monitor.type; |
| 358 | const widgetValue = getWidgetValue(dragTypeValue); |
| 359 | const widgetTypeExist = [ |
| 360 | "name", |
| 361 | "company", |
| 362 | "job title", |
| 363 | "email", |
| 364 | cellsWidget |
| 365 | ].includes(dragTypeValue); |
| 366 | const containerScale = getContainerScale( |
| 367 | pdfOriginalWH, |
| 368 | pageNumber, |
| 369 | containerWH |
| 370 | ); |
| 371 | const widgetWidth = |
| 372 | defaultWidthHeight(dragTypeValue).width * containerScale; |
| 373 | const widgetHeight = |
| 374 | defaultWidthHeight(dragTypeValue).height * containerScale; |
| 375 | //adding and updating drop position in array when user drop signature button in div |
| 376 | if (item === "onclick") { |
| 377 | // Use the current page container (id="container") so that the |
| 378 | // height reflects one page, not the entire multi-page document. |
| 379 | const containerEl = |
| 380 | document.getElementById("container") || divRef.current; |
| 381 | const divWidth = containerEl.getBoundingClientRect().width; |
| 382 | const divHeight = containerEl.getBoundingClientRect().height; |
| 383 | // Compute the pixel‐space center within the PDF viewport: |
| 384 | const centerX_Pixels = divWidth / 2 - widgetWidth / 2; |
| 385 | const xPosition_Final = centerX_Pixels / (containerScale * scale); |
| 386 | dropObj = { |
| 387 | //onclick put placeholder center on pdf |
| 388 | xPosition: xPosition_Final, |
| 389 | yPosition: |
| 390 | (divHeight / 2 - widgetHeight / 2) / (containerScale * scale), |
| 391 | isStamp: |
| 392 | (dragTypeValue === "stamp" || dragTypeValue === "image") && true, |
| 393 | key: key, |
| 394 | type: dragTypeValue, |
| 395 | scale: containerScale, |
| 396 | Width: widgetWidth / (containerScale * scale), |
| 397 | Height: widgetHeight / (containerScale * scale), |
| 398 | options: addWidgetSelfsignOptions( |
| 399 | dragTypeValue, |
| 400 | getWidgetValue, |
| 401 | owner, |
| 402 | xyPosition, |
| 403 | true |
| 404 | ) |
| 405 | }; |
| 406 | dropData.push(dropObj); |
nothing calls this directly
no test coverage detected