@vitrosoftware/common-ui-ts 1.1.230 → 1.1.231

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.
@@ -21208,7 +21208,7 @@ const defaultOptions = {
21208
21208
  kind: OptionKind.WORKER
21209
21209
  },
21210
21210
  workerSrc: {
21211
- value: "resource/pdfViewer/js/pdf.worker.js?version=1.1.230",
21211
+ value: "resource/pdfViewer/js/pdf.worker.js?version=1.1.231",
21212
21212
  kind: OptionKind.WORKER
21213
21213
  }
21214
21214
  };
@@ -37426,12 +37426,27 @@ const DOC_B = 'docB';
37426
37426
  let currentDocFileVersionList;
37427
37427
  let docAFileVersionList;
37428
37428
  let docBFileVersionList;
37429
+ fillVal = 'transparent';
37429
37430
 
37430
37431
  function initContextMenuCanvas() {
37431
37432
  var pages = '#viewer .page:not(.has-new-svg)';
37432
37433
  $.contextMenu({
37433
37434
  selector: pages,
37434
37435
  trigger: 'right',
37436
+ build: function ($triggerElement, e) {
37437
+ if ($('.svgsketch-wrap').hasClass('measures') || (e?.target && $(e?.target)?.hasClass('pdf-note'))
37438
+ || e?.target && ($(e?.target)?.attr('id') === MARKUP_EDIT_OUTLINE_ID || $(e?.target)?.hasClass(CSS_CLASS_MARKUP_RESIZER))) {
37439
+ return false;
37440
+ } else if (isTargetSvgMarkup(e)) {
37441
+ return {
37442
+ callback: function (key, options) { },
37443
+ items: getMarkupEditContextMenuItemList($triggerElement, e, true)
37444
+ }
37445
+ } else {
37446
+ return {
37447
+ callback: function (key, options) {
37448
+ $(document).trigger(key, [options, $triggerElement, e]);
37449
+ },
37435
37450
  items: {
37436
37451
  "addNote": {
37437
37452
  name: context.createLocale('app.viewer.pdf.contextMenu.addNote'),
@@ -37448,14 +37463,6 @@ function initContextMenuCanvas() {
37448
37463
  setContainerInset(0);
37449
37464
  }
37450
37465
  }
37451
- },
37452
- build: function ($triggerElement, e) {
37453
- if ($('.svgsketch-wrap').hasClass('measures') || (e?.target && $(e?.target)?.hasClass('pdf-note'))) {
37454
- return false;
37455
- } else {
37456
- return {
37457
- callback: function (key, options) {
37458
- $(document).trigger(key, [options, $triggerElement, e]);
37459
37466
  }
37460
37467
  };
37461
37468
  }
@@ -38974,6 +38981,15 @@ const CSS_CLASS_MARKUP_RESIZER = 'vitro-markup-resizer';
38974
38981
  const CSS_CLASS_PDF_NOTE = 'pdf-note';
38975
38982
  const CSS_CLASS_PAGE = 'page';
38976
38983
  const MARKUP_EDIT_OUTLINE_ID = 'markupEditOutline';
38984
+ const CSS_CLASS_CONTEXT_MENU_ICON = 'context-menu-icon';
38985
+ const CSS_CLASS_CONTEXT_MENU_ICON_EDIT = 'context-menu-icon-edit';
38986
+ const CSS_CLASS_CONTEXT_MENU_ICON_END_EDIT = 'context-menu-icon-end-edit';
38987
+ const CSS_CLASS_CONTEXT_MENU_ICON_CANCEL = 'context-menu-icon-quit';
38988
+ const CSS_CLASS_TOGGLED = 'toggled';
38989
+ const CONTEXT_MENU_SEP = "---------";
38990
+ const LOCALE_CONTEXT_MENU_EDIT = 'app.viewer.pdf.contextMenu.edit';
38991
+ const LOCALE_CONTEXT_MENU_END_EDIT = 'app.viewer.pdf.contextMenu.endEdit';
38992
+ const LOCALE_CONTEXT_MENU_CANCEL = 'app.viewer.pdf.contextMenu.cancel';
38977
38993
  let isMarkupEdit;
38978
38994
  let isMarkupMove;
38979
38995
  let isMarkupResize;
@@ -38983,13 +38999,13 @@ let markupUnderEditingSettings = {};
38983
38999
  let markupEditOutlineSettings = {};
38984
39000
 
38985
39001
 
38986
- function onMarkupEditStart(e) {
39002
+ function onMarkupEditStart(e, targetId) {
38987
39003
  setPdfViewerCursorToolMode();
38988
39004
  if (isMarkupEdit) {
38989
39005
  endMarkupEdit();
38990
39006
  }
38991
39007
  isMarkupEdit = true;
38992
- createMarkupEditOutline(e);
39008
+ createMarkupEditOutline(e, targetId);
38993
39009
  bindMouseUpEventHandler();
38994
39010
  bindOnMarkupEditEndHandler();
38995
39011
  }
@@ -39019,11 +39035,31 @@ function onMouseMove(e) {
39019
39035
  }
39020
39036
 
39021
39037
  function onMarkupMove(mouseX, mouseY) {
39022
- const x = markupEditOutlineSettings.position.x - markupMoveCoordinates.start.x + mouseX;
39023
- const y = markupEditOutlineSettings.position.y - markupMoveCoordinates.start.y + mouseY;
39038
+ let x = markupEditOutlineSettings.position.x - markupMoveCoordinates.start.x + mouseX;
39039
+ x = checkMarkupCoordinateX(x);
39040
+ let y = markupEditOutlineSettings.position.y - markupMoveCoordinates.start.y + mouseY;
39041
+ y = checkMarkupCoordinateY(y);
39024
39042
  setMarkupOutlinePosition($('#' + MARKUP_EDIT_OUTLINE_ID), x, y);
39025
39043
  }
39026
39044
 
39045
+ function checkMarkupCoordinateX(x) {
39046
+ if (x < 0) {
39047
+ return 0;
39048
+ } else if (x + $('#' + MARKUP_EDIT_OUTLINE_ID).width() > $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').width()) {
39049
+ return $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').width() - $('#' + MARKUP_EDIT_OUTLINE_ID).width();
39050
+ }
39051
+ return x;
39052
+ }
39053
+
39054
+ function checkMarkupCoordinateY(y) {
39055
+ if (y < 0) {
39056
+ return 0;
39057
+ } else if (y + $('#' + MARKUP_EDIT_OUTLINE_ID).height() > $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').height()) {
39058
+ return $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').height() - $('#' + MARKUP_EDIT_OUTLINE_ID).height();
39059
+ }
39060
+ return y;
39061
+ }
39062
+
39027
39063
  function onMarkupMoveEnd() {
39028
39064
  isMarkupMove = false;
39029
39065
  markupMoveCoordinates = {};
@@ -39042,14 +39078,14 @@ function refreshMarkupSimple() {
39042
39078
  let labelPosition = { ...markupEditOutlineSettings.position };
39043
39079
  const rotation = getPdfPagesRotation();
39044
39080
  if (rotation == 90) {
39045
- labelPosition.x = labelPosition.x + $('#markupEditOutline').height() + 1;
39081
+ labelPosition.x = labelPosition.x + $('#' + MARKUP_EDIT_OUTLINE_ID).height() + 1;
39046
39082
  }
39047
39083
  if (rotation == 180) {
39048
- labelPosition.x = labelPosition.x + $('#markupEditOutline').width() + 1;
39049
- labelPosition.y = labelPosition.y + $('#markupEditOutline').height() + 1;
39084
+ labelPosition.x = labelPosition.x + $('#' + MARKUP_EDIT_OUTLINE_ID).width() + 1;
39085
+ labelPosition.y = labelPosition.y + $('#' + MARKUP_EDIT_OUTLINE_ID).height() + 1;
39050
39086
  }
39051
39087
  if (rotation == 270) {
39052
- labelPosition.y = labelPosition.y + $('#markupEditOutline').width() + 1;
39088
+ labelPosition.y = labelPosition.y + $('#' + MARKUP_EDIT_OUTLINE_ID).width() + 1;
39053
39089
  }
39054
39090
  $('.pdf-note#' + markupUnderEditingSettings.issueId).css('left', labelPosition.x)
39055
39091
  .css('top', labelPosition.y);
@@ -39215,11 +39251,11 @@ function setMarkupSimpleUnderEditingSettingsNew() {
39215
39251
  const page = $('.' + CSS_CLASS_PAGE + '[data-page-number="' + markupUnderEditingSettings.markup.pageNr + '"]');
39216
39252
  const pageW = page.width();
39217
39253
  const pageH = page.height();
39218
-
39219
39254
 
39220
- if (rotation == 90) {
39255
+
39256
+ if (rotation == 90) {
39221
39257
  position.x = labelPos.top / scale;
39222
- position.y = pageW/scale - (labelPos.left / scale + labelElmHeight);
39258
+ position.y = pageW / scale - (labelPos.left / scale + labelElmHeight);
39223
39259
  } else if (rotation == 180) {
39224
39260
  position.x = pageW / scale - (labelPos.left / scale + labelElmWidth);
39225
39261
  position.y = pageH / scale - (labelPos.top / scale + labelElmHeight);
@@ -39227,9 +39263,9 @@ function setMarkupSimpleUnderEditingSettingsNew() {
39227
39263
  position.x = pageH / scale - (labelPos.top / scale + labelElmWidth);
39228
39264
  position.y = labelPos.left / scale;
39229
39265
  } else {
39230
- position.x = labelPos.left / scale;
39231
- position.y = labelPos.top / scale;
39232
- }
39266
+ position.x = labelPos.left / scale;
39267
+ position.y = labelPos.top / scale;
39268
+ }
39233
39269
 
39234
39270
  markupUnderEditingSettings.markup.position.x = position.x;
39235
39271
  markupUnderEditingSettings.markup.position.y = position.y;
@@ -39298,97 +39334,249 @@ function onMarkupResize(mouseX, mouseY) {
39298
39334
  }
39299
39335
 
39300
39336
  function getMarkupEditOutlineSettingsOnResizeTL(outlineWidth, outlineHeight, mouseX, mouseY, deltaX, deltaY) {
39337
+ let posX, posY, maxWidth, maxHeight;
39338
+ let x = (markupEditOutlineSettings.position.x + deltaX) <= (markupEditOutlineSettings.position.x + outlineWidth) ? (markupEditOutlineSettings.position.x + deltaX) : (markupEditOutlineSettings.position.x + outlineWidth);
39339
+ let y = (markupEditOutlineSettings.position.y + deltaY) <= (markupEditOutlineSettings.position.y + outlineHeight) ? (markupEditOutlineSettings.position.y + deltaY) : (markupEditOutlineSettings.position.y + outlineHeight);
39340
+
39341
+ if ((markupEditOutlineSettings.position.x + deltaX) <= (markupEditOutlineSettings.position.x + outlineWidth)) {
39342
+ const safeX = checkMarkupCoordinateX(x);
39343
+ deltaX = deltaX - (x - safeX);
39344
+ posX = safeX;
39345
+ maxWidth = markupEditOutlineSettings.position.x + outlineWidth;
39346
+ } else {
39347
+ posX = x;
39348
+ maxWidth = $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').width() - x;
39349
+ }
39350
+ const newWidth = Math.abs(outlineWidth - deltaX) > maxWidth ? maxWidth : Math.abs(outlineWidth - deltaX);
39351
+
39352
+ if ((markupEditOutlineSettings.position.y + deltaY) <= (markupEditOutlineSettings.position.y + outlineHeight)) {
39353
+ const safeY = checkMarkupCoordinateY(y);
39354
+ deltaY = deltaY - (y - safeY);
39355
+ posY = safeY;
39356
+ maxHeight = markupEditOutlineSettings.position.y + outlineHeight;
39357
+ } else {
39358
+ posY = y;
39359
+ maxHeight = $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').height() - y;
39360
+ }
39361
+ const newHeight = Math.abs(outlineHeight - deltaY) > maxHeight ? maxHeight : Math.abs(outlineHeight - deltaY);
39362
+
39301
39363
  const settings = {
39302
39364
  position: {
39303
- x: (markupEditOutlineSettings.position.x + deltaX) <= (markupEditOutlineSettings.position.x + outlineWidth) ? (markupEditOutlineSettings.position.x + deltaX) : (markupEditOutlineSettings.position.x + outlineWidth),
39304
- y: (markupEditOutlineSettings.position.y + deltaY) <= (markupEditOutlineSettings.position.y + outlineHeight) ? (markupEditOutlineSettings.position.y + deltaY) : (markupEditOutlineSettings.position.y + outlineHeight)
39365
+ x: posX,
39366
+ y: posY
39305
39367
  },
39306
- width: Math.abs(outlineWidth - deltaX),
39307
- height: Math.abs(outlineHeight - deltaY)
39368
+ width: newWidth,
39369
+ height: newHeight
39308
39370
  };
39309
39371
  return settings;
39310
39372
  }
39311
39373
 
39312
39374
  function getMarkupEditOutlineSettingsOnResizeTC(outlineWidth, outlineHeight, mouseY, deltaY) {
39375
+ let posY, maxHeight;
39376
+ let y = (markupEditOutlineSettings.position.y + deltaY) <= (markupEditOutlineSettings.position.y + outlineHeight) ? (markupEditOutlineSettings.position.y + deltaY) : (markupEditOutlineSettings.position.y + outlineHeight);
39377
+
39378
+ if ((markupEditOutlineSettings.position.y + deltaY) <= (markupEditOutlineSettings.position.y + outlineHeight)) {
39379
+ const safeY = checkMarkupCoordinateY(y);
39380
+ deltaY = deltaY - (y - safeY);
39381
+ posY = safeY;
39382
+ maxHeight = markupEditOutlineSettings.position.y + outlineHeight;
39383
+ } else {
39384
+ posY = y;
39385
+ maxHeight = $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').height() - y;
39386
+ }
39387
+ const newHeight = Math.abs(outlineHeight - deltaY) > maxHeight ? maxHeight : Math.abs(outlineHeight - deltaY);
39388
+
39313
39389
  const settings = {
39314
39390
  position: {
39315
39391
  x: markupEditOutlineSettings.position.x,
39316
- y: (markupEditOutlineSettings.position.y + deltaY) <= (markupEditOutlineSettings.position.y + outlineHeight) ? (markupEditOutlineSettings.position.y + deltaY) : (markupEditOutlineSettings.position.y + outlineHeight)
39392
+ y: posY
39317
39393
  },
39318
39394
  width: outlineWidth,
39319
- height: Math.abs(outlineHeight - deltaY)
39395
+ height: newHeight
39320
39396
  };
39321
39397
  return settings;
39322
39398
  }
39323
39399
 
39324
39400
  function getMarkupEditOutlineSettingsOnResizeTR(outlineWidth, outlineHeight, mouseX, mouseY, deltaX, deltaY) {
39401
+ let posX, posY, maxWidth, maxHeight;
39402
+ let x = (deltaX < 0 && Math.abs(deltaX) > outlineWidth) ? (markupEditOutlineSettings.position.x - Math.abs(deltaX) + outlineWidth) : markupEditOutlineSettings.position.x
39403
+ let y = (markupEditOutlineSettings.position.y + deltaY) <= (markupEditOutlineSettings.position.y + outlineHeight) ? (markupEditOutlineSettings.position.y + deltaY) : (markupEditOutlineSettings.position.y + outlineHeight);
39404
+
39405
+ if (deltaX < 0 && Math.abs(deltaX) > outlineWidth) {
39406
+ const safeX = checkMarkupCoordinateX(x);
39407
+ deltaX = deltaX - (x - safeX);
39408
+ posX = safeX;
39409
+ maxWidth = markupEditOutlineSettings.position.x + outlineWidth;
39410
+ } else {
39411
+ posX = x;
39412
+ maxWidth = $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').width() - x;
39413
+ }
39414
+ const newWidth = Math.abs(outlineWidth + deltaX) > maxWidth ? maxWidth : Math.abs(outlineWidth + deltaX);
39415
+ if ((markupEditOutlineSettings.position.y + deltaY) <= (markupEditOutlineSettings.position.y + outlineHeight)) {
39416
+ const safeY = checkMarkupCoordinateY(y);
39417
+ deltaY = deltaY - (y - safeY);
39418
+ posY = safeY;
39419
+ maxHeight = markupEditOutlineSettings.position.y + outlineHeight;
39420
+ } else {
39421
+ posY = y;
39422
+ maxHeight = $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').height() - y;
39423
+ }
39424
+ const newHeight = Math.abs(outlineHeight - deltaY) > maxHeight ? maxHeight : Math.abs(outlineHeight - deltaY);
39425
+
39325
39426
  const settings = {
39326
39427
  position: {
39327
- x: (deltaX < 0 && Math.abs(deltaX) > outlineWidth) ? (markupEditOutlineSettings.position.x - Math.abs(deltaX) + outlineWidth) : markupEditOutlineSettings.position.x,
39328
- y: (markupEditOutlineSettings.position.y + deltaY) <= (markupEditOutlineSettings.position.y + outlineHeight) ? (markupEditOutlineSettings.position.y + deltaY) : (markupEditOutlineSettings.position.y + outlineHeight)
39428
+ x: posX,
39429
+ y: posY
39329
39430
  },
39330
- width: Math.abs(outlineWidth + deltaX),
39331
- height: Math.abs(outlineHeight - deltaY)
39431
+ width: newWidth,
39432
+ height: newHeight
39332
39433
  };
39333
39434
  return settings;
39334
39435
  }
39335
39436
 
39336
39437
  function getMarkupEditOutlineSettingsOnResizeCL(outlineWidth, outlineHeight, mouseX, deltaX) {
39438
+ let posX, maxWidth;
39439
+ let x = (markupEditOutlineSettings.position.x + deltaX) <= (markupEditOutlineSettings.position.x + outlineWidth) ? (markupEditOutlineSettings.position.x + deltaX) : (markupEditOutlineSettings.position.x + outlineWidth);
39440
+
39441
+ if ((markupEditOutlineSettings.position.x + deltaX) <= (markupEditOutlineSettings.position.x + outlineWidth)) {
39442
+ const safeX = checkMarkupCoordinateX(x);
39443
+ deltaX = deltaX - (x - safeX);
39444
+ posX = safeX;
39445
+ maxWidth = markupEditOutlineSettings.position.x + outlineWidth;
39446
+ } else {
39447
+ posX = x;
39448
+ maxWidth = $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').width() - x;
39449
+ }
39450
+ const newWidth = Math.abs(outlineWidth - deltaX) > maxWidth ? maxWidth : Math.abs(outlineWidth - deltaX);
39451
+
39337
39452
  const settings = {
39338
39453
  position: {
39339
- x: (markupEditOutlineSettings.position.x + deltaX) <= (markupEditOutlineSettings.position.x + outlineWidth) ? (markupEditOutlineSettings.position.x + deltaX) : (markupEditOutlineSettings.position.x + outlineWidth),
39340
- y: markupEditOutlineSettings.position.y,
39454
+ x: posX,
39455
+ y: markupEditOutlineSettings.position.y
39341
39456
  },
39342
- width: Math.abs(outlineWidth - deltaX),
39457
+ width: newWidth,
39343
39458
  height: outlineHeight
39344
39459
  };
39345
39460
  return settings;
39346
39461
  }
39347
39462
 
39348
39463
  function getMarkupEditOutlineSettingsOnResizeCR(outlineWidth, outlineHeight, mouseX, deltaX) {
39464
+ let posX, maxWidth;
39465
+ let x = (deltaX < 0 && Math.abs(deltaX) > outlineWidth) ? (markupEditOutlineSettings.position.x - Math.abs(deltaX) + outlineWidth) : markupEditOutlineSettings.position.x
39466
+ if (deltaX < 0 && Math.abs(deltaX) > outlineWidth) {
39467
+ const safeX = checkMarkupCoordinateX(x);
39468
+ deltaX = deltaX - (x - safeX);
39469
+ posX = safeX;
39470
+ maxWidth = markupEditOutlineSettings.position.x + outlineWidth;
39471
+ } else {
39472
+ posX = x;
39473
+ maxWidth = $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').width() - x;
39474
+ }
39475
+ const newWidth = Math.abs(outlineWidth + deltaX) > maxWidth ? maxWidth : Math.abs(outlineWidth + deltaX);
39349
39476
  const settings = {
39350
39477
  position: {
39351
- x: (deltaX < 0 && Math.abs(deltaX) > outlineWidth) ? (markupEditOutlineSettings.position.x - Math.abs(deltaX) + outlineWidth) : markupEditOutlineSettings.position.x,
39478
+ x: posX,
39352
39479
  y: markupEditOutlineSettings.position.y,
39353
39480
  },
39354
- width: Math.abs(outlineWidth + deltaX),
39481
+ width: newWidth,
39355
39482
  height: outlineHeight
39356
39483
  };
39357
39484
  return settings;
39358
39485
  }
39359
39486
 
39360
39487
  function getMarkupEditOutlineSettingsOnResizeBL(outlineWidth, outlineHeight, mouseX, mouseY, deltaX, deltaY) {
39488
+ let posX, posY, maxWidth, maxHeight;
39489
+ let x = (markupEditOutlineSettings.position.x + deltaX) <= (markupEditOutlineSettings.position.x + outlineWidth) ? (markupEditOutlineSettings.position.x + deltaX) : (markupEditOutlineSettings.position.x + outlineWidth);
39490
+ let y = (deltaY < 0 && Math.abs(deltaY) > outlineHeight) ? (markupEditOutlineSettings.position.y - Math.abs(deltaY) + outlineHeight) : markupEditOutlineSettings.position.y;
39491
+
39492
+ if ((markupEditOutlineSettings.position.x + deltaX) <= (markupEditOutlineSettings.position.x + outlineWidth)) {
39493
+ const safeX = checkMarkupCoordinateX(x);
39494
+ deltaX = deltaX - (x - safeX);
39495
+ posX = safeX;
39496
+ maxWidth = markupEditOutlineSettings.position.x + outlineWidth;
39497
+ } else {
39498
+ posX = x;
39499
+ maxWidth = $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').width() - x;
39500
+ }
39501
+ const newWidth = Math.abs(outlineWidth - deltaX) > maxWidth ? maxWidth : Math.abs(outlineWidth - deltaX);
39502
+
39503
+ if ((deltaY < 0 && Math.abs(deltaY) > outlineHeight)) {
39504
+ const safeY = checkMarkupCoordinateY(y);
39505
+ deltaY = deltaY - (y - safeY);
39506
+ posY = safeY;
39507
+ maxHeight = markupEditOutlineSettings.position.y + outlineHeight;
39508
+ } else {
39509
+ posY = y;
39510
+ maxHeight = $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').height() - y;
39511
+ }
39512
+ const newHeight = Math.abs(outlineHeight + deltaY) > maxHeight ? maxHeight : Math.abs(outlineHeight + deltaY);
39513
+
39361
39514
  const settings = {
39362
39515
  position: {
39363
- x: (markupEditOutlineSettings.position.x + deltaX) <= (markupEditOutlineSettings.position.x + outlineWidth) ? (markupEditOutlineSettings.position.x + deltaX) : (markupEditOutlineSettings.position.x + outlineWidth),
39364
- y: (deltaY < 0 && Math.abs(deltaY) > outlineHeight) ? (markupEditOutlineSettings.position.y - Math.abs(deltaY) + outlineHeight) : markupEditOutlineSettings.position.y
39516
+ x: posX,
39517
+ y: posY
39365
39518
  },
39366
- width: Math.abs(outlineWidth - deltaX),
39367
- height: Math.abs(outlineHeight + deltaY)
39519
+ width: newWidth,
39520
+ height: newHeight
39368
39521
  };
39369
39522
  return settings;
39370
39523
  }
39371
39524
 
39372
39525
  function getMarkupEditOutlineSettingsOnResizeBC(outlineWidth, outlineHeight, mouseY, deltaY) {
39526
+ let posY, maxHeight;
39527
+ let y = (deltaY < 0 && Math.abs(deltaY) > outlineHeight) ? (markupEditOutlineSettings.position.y - Math.abs(deltaY) + outlineHeight) : markupEditOutlineSettings.position.y;
39528
+ if ((deltaY < 0 && Math.abs(deltaY) > outlineHeight)) {
39529
+ const safeY = checkMarkupCoordinateY(y);
39530
+ deltaY = deltaY - (y - safeY);
39531
+ posY = safeY;
39532
+ maxHeight = markupEditOutlineSettings.position.y + outlineHeight;
39533
+ } else {
39534
+ posY = y;
39535
+ maxHeight = $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').height() - y;
39536
+ }
39537
+ const newHeight = Math.abs(outlineHeight + deltaY) > maxHeight ? maxHeight : Math.abs(outlineHeight + deltaY);
39373
39538
  const settings = {
39374
39539
  position: {
39375
39540
  x: markupEditOutlineSettings.position.x,
39376
39541
  y: (deltaY < 0 && Math.abs(deltaY) > outlineHeight) ? (markupEditOutlineSettings.position.y - Math.abs(deltaY) + outlineHeight) : markupEditOutlineSettings.position.y
39377
39542
  },
39378
39543
  width: outlineWidth,
39379
- height: Math.abs(outlineHeight + deltaY)
39544
+ height: newHeight
39380
39545
  };
39381
39546
  return settings;
39382
39547
  }
39383
39548
 
39384
39549
  function getMarkupEditOutlineSettingsOnResizeBR(outlineWidth, outlineHeight, mouseX, mouseY, deltaX, deltaY) {
39550
+ let posX, posY, maxWidth, maxHeight;
39551
+ let x = (deltaX < 0 && Math.abs(deltaX) > outlineWidth) ? (markupEditOutlineSettings.position.x - Math.abs(deltaX) + outlineWidth) : markupEditOutlineSettings.position.x;
39552
+ let y = (deltaY < 0 && Math.abs(deltaY) > outlineHeight) ? (markupEditOutlineSettings.position.y - Math.abs(deltaY) + outlineHeight) : markupEditOutlineSettings.position.y;
39553
+ if (deltaX < 0 && Math.abs(deltaX) > outlineWidth) {
39554
+ const safeX = checkMarkupCoordinateX(x);
39555
+ deltaX = deltaX - (x - safeX);
39556
+ posX = safeX;
39557
+ maxWidth = markupEditOutlineSettings.position.x + outlineWidth;
39558
+ } else {
39559
+ posX = x;
39560
+ maxWidth = $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').width() - x;
39561
+ }
39562
+ const newWidth = Math.abs(outlineWidth + deltaX) > maxWidth ? maxWidth : Math.abs(outlineWidth + deltaX);
39563
+ if ((deltaY < 0 && Math.abs(deltaY) > outlineHeight)) {
39564
+ const safeY = checkMarkupCoordinateY(y);
39565
+ deltaY = deltaY - (y - safeY);
39566
+ posY = safeY;
39567
+ maxHeight = markupEditOutlineSettings.position.y + outlineHeight;
39568
+ } else {
39569
+ posY = y;
39570
+ maxHeight = $('#' + MARKUP_EDIT_OUTLINE_ID).closest('.page').height() - y;
39571
+ }
39572
+ const newHeight = Math.abs(outlineHeight + deltaY) > maxHeight ? maxHeight : Math.abs(outlineHeight + deltaY);
39385
39573
  const settings = {
39386
39574
  position: {
39387
- x: (deltaX < 0 && Math.abs(deltaX) > outlineWidth) ? (markupEditOutlineSettings.position.x - Math.abs(deltaX) + outlineWidth) : markupEditOutlineSettings.position.x,
39388
- y: (deltaY < 0 && Math.abs(deltaY) > outlineHeight) ? (markupEditOutlineSettings.position.y - Math.abs(deltaY) + outlineHeight) : markupEditOutlineSettings.position.y
39575
+ x: posX,
39576
+ y: posY
39389
39577
  },
39390
- width: Math.abs(outlineWidth + deltaX),
39391
- height: Math.abs(outlineHeight + deltaY)
39578
+ width: newWidth,
39579
+ height: newHeight
39392
39580
  };
39393
39581
  return settings;
39394
39582
  }
@@ -39418,19 +39606,34 @@ function setMarkupEditOutlineSettingsNew() {
39418
39606
  }
39419
39607
 
39420
39608
  function bindOnMarkupEditEndHandler() {
39421
- window.addEventListener('keydown', onMarkupEditEnd);
39609
+ window.addEventListener('keydown', onMarkupEditEndKeydownHandler);
39610
+ window.addEventListener('mousedown', onMarkupEditEndMousedownHandler);
39422
39611
  }
39423
39612
 
39424
39613
  function unbindOnMarkupEditEndHandler() {
39425
- window.removeEventListener('keydown', onMarkupEditEnd);
39614
+ window.removeEventListener('keydown', onMarkupEditEndKeydownHandler);
39615
+ window.removeEventListener('mousedown', onMarkupEditEndMousedownHandler);
39616
+ }
39617
+
39618
+ function onMarkupEditEndKeydownHandler(e) {
39619
+ if ((e.key === 'Escape' && isMarkupEdit) || (isClickOutsideMarkupEdit(e))) {
39620
+ endMarkupEdit();
39621
+ }
39426
39622
  }
39427
39623
 
39428
- function onMarkupEditEnd(e) {
39429
- if (e.key === 'Escape' && isMarkupEdit) {
39624
+ function onMarkupEditEndMousedownHandler(e) {
39625
+ if (e.button === 0 && isClickOutsideMarkupEdit(e)) {
39430
39626
  endMarkupEdit();
39431
39627
  }
39432
39628
  }
39433
39629
 
39630
+ function isClickOutsideMarkupEdit(e) {
39631
+ return !(e.target && ($(e?.target)?.hasClass(CSS_CLASS_MARKUP_RESIZER) || $(e?.target)?.attr('id') === MARKUP_EDIT_OUTLINE_ID)
39632
+ || $(e?.target)?.hasClass(CSS_CLASS_CONTEXT_MENU_ICON_CANCEL) || $(e?.target)?.parent()?.hasClass(CSS_CLASS_CONTEXT_MENU_ICON_CANCEL)
39633
+ || $(e?.target)?.hasClass(CSS_CLASS_CONTEXT_MENU_ICON_END_EDIT) || $(e?.target)?.parent()?.hasClass(CSS_CLASS_CONTEXT_MENU_ICON_END_EDIT)
39634
+ || $(e?.target)?.hasClass(CSS_CLASS_CONTEXT_MENU_ICON_EDIT) || $(e?.target)?.parent()?.hasClass(CSS_CLASS_CONTEXT_MENU_ICON_EDIT));
39635
+ }
39636
+
39434
39637
  function endMarkupEdit() {
39435
39638
  isMarkupEdit = false;
39436
39639
  saveMarkup();
@@ -39455,11 +39658,11 @@ function removeMarkupEditOutline() {
39455
39658
  document.getElementById(MARKUP_EDIT_OUTLINE_ID)?.remove();
39456
39659
  }
39457
39660
 
39458
- function createMarkupEditOutline(e) {
39661
+ function createMarkupEditOutline(e, targetId) {
39459
39662
  if (e?.target) {
39460
39663
  removeMarkupEditOutline();
39461
39664
  const page = $(e.target).closest('.' + CSS_CLASS_PAGE);
39462
- const markupSettings = getMarkupSettings(e.target);
39665
+ const markupSettings = getMarkupSettings(e.target, targetId);
39463
39666
  doCreateMarkupEditOutline(page, markupSettings);
39464
39667
  }
39465
39668
  }
@@ -39628,8 +39831,9 @@ function getMarkupEditOutlinePositionRotation270Deg(markupSettings, scale, svgsk
39628
39831
  return position;
39629
39832
  }
39630
39833
 
39631
- function getMarkupSettings(target) {
39632
- const issue = context.issueList.find(item => item.id === target.id);
39834
+ function getMarkupSettings(target, targetId) {
39835
+ const id = targetId ? targetId : target.id;
39836
+ const issue = context.issueList.find(item => item.id === id);
39633
39837
  if (issue) {
39634
39838
  const markup = issue?.markup ? JSON.parse(issue?.markup) : undefined;
39635
39839
  markupUnderEditingSettings = { issueId: issue.id, markup: markup }
@@ -39681,37 +39885,109 @@ function initMarkupEditContextMenu() {
39681
39885
  });
39682
39886
  }
39683
39887
 
39684
- function getMarkupEditContextMenuItemList($triggerElement, e) {
39685
- const menuItems = {
39686
- "editMarkup": {
39687
- name: context.createLocale('app.viewer.pdf.contextMenu.edit'),
39688
- callback: function (key, options) {
39689
- onMarkupEditStart(e);
39888
+ function initMarkupOutlineEditContextMenu() {
39889
+ const selector = '#' + MARKUP_EDIT_OUTLINE_ID;
39890
+ $.contextMenu({
39891
+ selector: selector,
39892
+ trigger: 'right',
39893
+ build: function ($triggerElement, e) {
39894
+ return {
39895
+ callback: function (key, options) { },
39896
+ items: getMarkupEditContextMenuItemList($triggerElement, e)
39897
+ }
39898
+ }
39899
+ });
39900
+ }
39901
+
39902
+ function getMarkupEditContextMenuItemList($triggerElement, e, isSvgMarkup) {
39903
+ const menuItems = {};
39904
+ if (isMarkupEdit && (markupUnderEditingSettings.issueId === $triggerElement.attr('id')
39905
+ || $triggerElement.attr('id') === MARKUP_EDIT_OUTLINE_ID)) {
39906
+ menuItems.endEditMarkup = getMarkupEditContextMenuItemEndEditMarkup();
39907
+ } else {
39908
+ menuItems.editMarkup = getMarkupEditContextMenuItemEditMarkup(e, isSvgMarkup);
39909
+ }
39910
+ menuItems.sep1 = getMarkupEditContextMenuSep();
39911
+ menuItems.quit = getMarkupEditContextMenuItemCancel();
39912
+ return menuItems;
39913
+ }
39914
+
39915
+ function getMarkupEditContextMenuItemEditMarkup(e, isSvgMarkup) {
39916
+ return {
39917
+ name: context.createLocale(LOCALE_CONTEXT_MENU_EDIT),
39918
+ callback: function (key, options) {
39919
+ let targetId;
39920
+ if (isSvgMarkup) {
39921
+ targetId = e.target.id?.replace('svg-', '');
39690
39922
  }
39923
+ onMarkupEditStart(e, targetId);
39691
39924
  },
39692
- "sep1": "---------",
39693
- "quit": {
39694
- name: context.createLocale('app.viewer.pdf.contextMenu.cancel'),
39695
- icon: function () {
39696
- return 'context-menu-icon context-menu-icon-quit';
39697
- },
39925
+ icon: function () {
39926
+ return CSS_CLASS_CONTEXT_MENU_ICON + ' ' + CSS_CLASS_CONTEXT_MENU_ICON_EDIT;
39927
+ }
39928
+ };
39929
+ }
39930
+
39931
+ function getMarkupEditContextMenuItemEndEditMarkup() {
39932
+ return {
39933
+ name: context.createLocale(LOCALE_CONTEXT_MENU_END_EDIT),
39934
+ callback: function (key, options) {
39935
+ endMarkupEdit();
39936
+ },
39937
+ icon: function () {
39938
+ return CSS_CLASS_CONTEXT_MENU_ICON + ' ' + CSS_CLASS_CONTEXT_MENU_ICON_END_EDIT;
39698
39939
  }
39699
39940
  };
39700
- return menuItems;
39941
+ }
39942
+
39943
+ function getMarkupEditContextMenuItemCancel() {
39944
+ return {
39945
+ name: context.createLocale(LOCALE_CONTEXT_MENU_CANCEL),
39946
+ icon: function () {
39947
+ return CSS_CLASS_CONTEXT_MENU_ICON + ' ' + CSS_CLASS_CONTEXT_MENU_ICON_CANCEL;
39948
+ }
39949
+ };
39950
+ }
39951
+
39952
+ function getMarkupEditContextMenuSep() {
39953
+ return CONTEXT_MENU_SEP;
39701
39954
  }
39702
39955
 
39703
39956
  function setPdfViewerCursorToolMode() {
39704
39957
  const btnCursorTool = $('#cursorSelectTool');
39705
39958
  const btnDrawAnnotation = $('#btnDrawAnnotation');
39706
- if (btnDrawAnnotation.hasClass('toggled')) {
39959
+ if (btnDrawAnnotation.hasClass(CSS_CLASS_TOGGLED)) {
39707
39960
  btnDrawAnnotation.click();
39708
39961
  }
39709
- if (!btnCursorTool.hasClass('toggled')) {
39962
+ if (!btnCursorTool.hasClass(CSS_CLASS_TOGGLED)) {
39710
39963
  btnCursorTool.click();
39711
39964
  }
39712
39965
  }
39713
39966
 
39714
- initMarkupEditContextMenu();
39967
+ function isTargetSvgMarkup(e) {
39968
+ return (e?.target && !e?.target?.id?.startsWith('surface-') && (e?.target.tagName === 'rect' || e?.target.tagName === 'path'
39969
+ || e?.target.tagName === 'line' || e?.target.tagName === 'polygon'
39970
+ || e?.target.tagName === 'ellipse'));
39971
+ }
39972
+
39973
+ function bindSvgSketchpadMouseEventHandler() {
39974
+ window.addEventListener('mousedown', svgSketchpadMouseDownEventHandler);
39975
+ window.addEventListener('mouseup', svgSketchpadMouseUpEventHandler);
39976
+ }
39977
+
39978
+ function svgSketchpadMouseDownEventHandler(e) {
39979
+ if (e.button == 0 && !$(e.target)?.closest('.page')?.find('.svgsketch-wrap')?.hasClass('active')) {
39980
+ $(e?.target)?.closest('.page')?.find('.svgsketch-wrap')?.addClass('to-bg');
39981
+ }
39982
+ }
39983
+
39984
+ function svgSketchpadMouseUpEventHandler(e) {
39985
+ $(e?.target)?.closest('.page')?.find('.svgsketch-wrap')?.removeClass('to-bg');
39986
+ }
39987
+
39988
+ initMarkupEditContextMenu();
39989
+ initMarkupOutlineEditContextMenu();
39990
+ bindSvgSketchpadMouseEventHandler();
39715
39991
  $(document).ready(function() {
39716
39992
  context.openFile();
39717
39993