@yoobic/yobi 8.1.0-30 → 8.1.0-31

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.
@@ -317,8 +317,9 @@ function centerAnnotation(annotation, containerElement) {
317
317
  const imageBounding = containerElement.getBoundingClientRect();
318
318
  const activeElementBounding = element.getBoundingClientRect();
319
319
  const getAbsoluteCenter = (axis) => {
320
+ var _a;
320
321
  const isX = axis === 'x';
321
- return (getDraggable(element)[axis] +
322
+ return lodash.isFinite((_a = getDraggable(element)) === null || _a === void 0 ? void 0 : _a[axis]) && (getDraggable(element)[axis] +
322
323
  imageBounding[isX ? 'width' : 'height'] / 2 +
323
324
  imageBounding[axis] -
324
325
  (activeElementBounding[axis] + activeElementBounding[isX ? 'width' : 'height'] / 2));
@@ -6,7 +6,7 @@ const index = require('./index-f4b5bbb5.js');
6
6
  require('./index-4c9e171d.js');
7
7
  const annotationsHelpers = require('./annotations-helpers-48180ded.js');
8
8
  const commonHelpers = require('./common-helpers-861856bf.js');
9
- const draggableDotsHelpers = require('./draggable-dots-helpers-37497e75.js');
9
+ const draggableDotsHelpers = require('./draggable-dots-helpers-baee58b9.js');
10
10
  const overlays = require('./overlays-29c8808e.js');
11
11
  require('./lodash-a046a0e1.js');
12
12
  require('./index-ce0514fc.js');
@@ -9,7 +9,7 @@ const index$1 = require('./index-4c9e171d.js');
9
9
  const lodash = require('./lodash-a046a0e1.js');
10
10
  const annotationsHelpers = require('./annotations-helpers-48180ded.js');
11
11
  const commonHelpers = require('./common-helpers-861856bf.js');
12
- const draggableDotsHelpers = require('./draggable-dots-helpers-37497e75.js');
12
+ const draggableDotsHelpers = require('./draggable-dots-helpers-baee58b9.js');
13
13
  const formInputHelpers = require('./form-input-helpers-127e9fa0.js');
14
14
  require('./index-ce0514fc.js');
15
15
  require('./_commonjsHelpers-94df2ea7.js');
@@ -412,7 +412,7 @@ let YooPhotoEditorComponent = class {
412
412
  };
413
413
  }
414
414
  get imageSizeStyle() {
415
- const getSize = (type) => { var _a; return (_a = this.imageSize) === null || _a === void 0 ? void 0 : _a[type]; };
415
+ const getSize = (type) => this.imageSize[type];
416
416
  const getStyle = (type) => {
417
417
  var _a, _b;
418
418
  return ({
@@ -420,7 +420,7 @@ let YooPhotoEditorComponent = class {
420
420
  width: `${(_b = getSize(type)) === null || _b === void 0 ? void 0 : _b.width}px`
421
421
  });
422
422
  };
423
- return {
423
+ return this.imageSize && {
424
424
  natural: getStyle('natural'),
425
425
  resized: getStyle('resized')
426
426
  };
@@ -579,16 +579,18 @@ let YooPhotoEditorComponent = class {
579
579
  this.hasDoneBeenClicked = newValue === 'tools';
580
580
  this.toggleSaveButton();
581
581
  this.toggleColorSelector();
582
- this.toggleDraggableAnnotations();
583
582
  }
584
583
  }
584
+ componentDidRender() {
585
+ this.toggleDraggableAnnotations();
586
+ this.updateDraggableBoundings();
587
+ }
585
588
  disconnectedCallback() {
586
589
  this.toggleKeyboardListeners(false);
587
590
  !this.isPreview && overlays.setStatusBarDarkMode(false);
588
591
  }
589
592
  initEditor() {
590
593
  this.initResizeObserver();
591
- this.toggleDraggableAnnotations();
592
594
  this.toggleKeyboardListeners(true);
593
595
  !this.isPreview && overlays.setStatusBarDarkMode(true);
594
596
  this.savedAnnotationElements = lodash.cloneDeep(this.annotationElements);
@@ -637,7 +639,6 @@ let YooPhotoEditorComponent = class {
637
639
  if (!this.isReadonly) {
638
640
  this.showActiveTooltip();
639
641
  this.toggleShowNavbar(this.navbarVisiblity !== 'hidden');
640
- this.toggleDraggableAnnotations();
641
642
  formInputHelpers.focusContentEditable(this.activeElement);
642
643
  if (this.hasAnnotationBeenCreated) {
643
644
  this.attachNewAnnotation();
@@ -739,7 +740,6 @@ let YooPhotoEditorComponent = class {
739
740
  this.blockMoves.emit(true);
740
741
  if (this.activeElement) {
741
742
  this.toggleShowNavbar(false);
742
- this.updateDraggableBoundings();
743
743
  this.bottomContainerElement.classList.remove('active');
744
744
  getActionButton().validate.classList.remove('active');
745
745
  getActionButton().delete.classList.add('active');
@@ -954,7 +954,6 @@ let YooPhotoEditorComponent = class {
954
954
  const borderColor = this.isDotEditMode ? defaultAnnotationTextColor : 'none';
955
955
  if (this.isTextMode) {
956
956
  this.updateAnnotationStyle('textColor', color);
957
- // focusContentEditable(this.activeElement);
958
957
  }
959
958
  el && Object.assign(el.style, { borderColor, color, backgroundColor });
960
959
  this.updateAnnotationStyle('backgroundColor', backgroundColor);
@@ -1054,18 +1053,17 @@ let YooPhotoEditorComponent = class {
1054
1053
  }
1055
1054
  createTextBox() {
1056
1055
  var _a, _b, _c, _d, _e;
1056
+ const getPercentPosition = (bound) => {
1057
+ return ((this.imageBounds[bound] / 2 - this.activeElement[`client${lodash.capitalize(bound)}`] / 2) / this.imageBounds[bound]) * 100;
1058
+ };
1057
1059
  this.isTextCreateMode = false;
1058
1060
  this.hasAnnotationBeenCreated = true;
1059
1061
  this.annotations.push({
1060
1062
  ...draggableDotsHelpers.createBaseAnnotation('text'),
1061
1063
  text: ((_a = this.activeElement) === null || _a === void 0 ? void 0 : _a.innerText) || '',
1062
- _local: {
1063
- transform: {
1064
- current: {
1065
- x: parseFloat(this.activeElement.style.left),
1066
- y: parseFloat(this.activeElement.style.top)
1067
- }
1068
- }
1064
+ coords: {
1065
+ percentX: getPercentPosition('width'),
1066
+ percentY: getPercentPosition('height')
1069
1067
  },
1070
1068
  styles: {
1071
1069
  fontSize: this.size || draggableDotsHelpers.SLIDER_THRESHOLD.text.default,
@@ -1209,6 +1207,7 @@ let YooPhotoEditorComponent = class {
1209
1207
  (_a = this.annotationElements) === null || _a === void 0 ? void 0 : _a.forEach(e => {
1210
1208
  if (e) {
1211
1209
  e.classList.remove('hidden');
1210
+ e.classList.toggle('draggable', enableDraggable);
1212
1211
  overlays.Draggable.get(e) ? overlays.Draggable.get(e)[enableDraggable ? 'enable' : 'disable']() : this.getDraggableActions(e)[enableDraggable ? 'enable' : 'disable']();
1213
1212
  //bypass fix gsap draggable auto-generating user-select on editing a focusing textbox
1214
1213
  ['user-select', '-webkit-user-select', '-moz-user-select'].forEach(us => e.style.removeProperty(us));
@@ -1382,8 +1381,8 @@ let YooPhotoEditorComponent = class {
1382
1381
  return this.navbarVisiblity !== 'disabled' && !this.isPreview && index.h(Navbar, { visibility: this.navbarVisiblity, animated: this.mode !== this.lastMode, currentOptions: this.menuOptions.getOptions()[this.mode], onOptionClick: (ev, btnContent) => this.optionsClick(ev, btnContent) });
1383
1382
  }
1384
1383
  renderAnnotations() {
1385
- var _a;
1386
- return !this.isLoading && (this.displayAnnotations || !this.isReadonly) && (index.h("section", { class: "annotations", style: this.imageSizeStyle.resized, ref: el => this.annotationsContainerElement = el }, (_a = this.annotations) === null || _a === void 0 ? void 0 : _a.map(a => a && (a === null || a === void 0 ? void 0 : a.type) === 'dot' ? this.renderDot(a) : this.renderTextbox(a))));
1384
+ var _a, _b, _c;
1385
+ return !this.isLoading && ((_b = (_a = this.imageSizeStyle) === null || _a === void 0 ? void 0 : _a.resized) === null || _b === void 0 ? void 0 : _b.width) && (this.displayAnnotations || !this.isReadonly) && (index.h("section", { class: "annotations", style: this.imageSizeStyle.resized, ref: el => this.annotationsContainerElement = el }, (_c = this.annotations) === null || _c === void 0 ? void 0 : _c.map(a => (a === null || a === void 0 ? void 0 : a.type) === 'dot' ? this.renderDot(a) : this.renderTextbox(a))));
1387
1386
  }
1388
1387
  renderSrcCanvas() {
1389
1388
  return index.h("canvas", { id: "src", onClick: (ev) => ev.preventDefault(), ref: el => this.canvasSrcElement = el, ...this.computedImageSize });
@@ -250,8 +250,9 @@ function centerAnnotation(annotation, containerElement) {
250
250
  const imageBounding = containerElement.getBoundingClientRect();
251
251
  const activeElementBounding = element.getBoundingClientRect();
252
252
  const getAbsoluteCenter = (axis) => {
253
+ var _a;
253
254
  const isX = axis === 'x';
254
- return (getDraggable(element)[axis] +
255
+ return isFinite((_a = getDraggable(element)) === null || _a === void 0 ? void 0 : _a[axis]) && (getDraggable(element)[axis] +
255
256
  imageBounding[isX ? 'width' : 'height'] / 2 +
256
257
  imageBounding[axis] -
257
258
  (activeElementBounding[axis] + activeElementBounding[isX ? 'width' : 'height'] / 2));
@@ -18,7 +18,7 @@ import { ScreenOrientation } from '@ionic-native/screen-orientation';
18
18
  import { TapticEngine } from '@ionic-native/taptic-engine';
19
19
  import { cleanupWKWebViewFilePath, closeModal, Draggable, enableKeyboardResize, getAsyncExtraData, getContrastColor, getCssColor, getImageScaleFactor, getImageSize, getMedia, getResizedImageSize, getTransformInfos, gsapSet, gsapTo, isIOS, isNativeMobile, isWeb, resizeObserve, scaleUpAnimation, setStatusBarDarkMode, showActionSheet, showAlert, showContextMenu, translate } from '@shared/utils';
20
20
  import { Component, Element, Event, forceUpdate, h, Host, Method, Prop, State, Watch } from '@stencil/core';
21
- import { cloneDeep, isEqual, isFunction } from 'lodash-es';
21
+ import { capitalize, cloneDeep, isEqual, isFunction } from 'lodash-es';
22
22
  import { getElement, getPointerCoordinates, isAnnotationDeleted, isAnnotationEmpty, isAnnotationFocused, isAnnotationValid, isElementInsideContainer } from '../../../utils/helpers/annotations-helpers';
23
23
  import { cloudinary } from '../../../utils/helpers/common-helpers';
24
24
  import { createDot, getDotInnerElement, getDotToolTipElement, hideAllDotTooltips, setDotIndexes, showDotTooltip } from '../../../utils/helpers/draggable-dots-helpers';
@@ -239,7 +239,7 @@ export class YooPhotoEditorComponent {
239
239
  };
240
240
  }
241
241
  get imageSizeStyle() {
242
- const getSize = (type) => { var _a; return (_a = this.imageSize) === null || _a === void 0 ? void 0 : _a[type]; };
242
+ const getSize = (type) => this.imageSize[type];
243
243
  const getStyle = (type) => {
244
244
  var _a, _b;
245
245
  return ({
@@ -247,7 +247,7 @@ export class YooPhotoEditorComponent {
247
247
  width: `${(_b = getSize(type)) === null || _b === void 0 ? void 0 : _b.width}px`
248
248
  });
249
249
  };
250
- return {
250
+ return this.imageSize && {
251
251
  natural: getStyle('natural'),
252
252
  resized: getStyle('resized')
253
253
  };
@@ -406,16 +406,18 @@ export class YooPhotoEditorComponent {
406
406
  this.hasDoneBeenClicked = newValue === 'tools';
407
407
  this.toggleSaveButton();
408
408
  this.toggleColorSelector();
409
- this.toggleDraggableAnnotations();
410
409
  }
411
410
  }
411
+ componentDidRender() {
412
+ this.toggleDraggableAnnotations();
413
+ this.updateDraggableBoundings();
414
+ }
412
415
  disconnectedCallback() {
413
416
  this.toggleKeyboardListeners(false);
414
417
  !this.isPreview && setStatusBarDarkMode(false);
415
418
  }
416
419
  initEditor() {
417
420
  this.initResizeObserver();
418
- this.toggleDraggableAnnotations();
419
421
  this.toggleKeyboardListeners(true);
420
422
  !this.isPreview && setStatusBarDarkMode(true);
421
423
  this.savedAnnotationElements = cloneDeep(this.annotationElements);
@@ -464,7 +466,6 @@ export class YooPhotoEditorComponent {
464
466
  if (!this.isReadonly) {
465
467
  this.showActiveTooltip();
466
468
  this.toggleShowNavbar(this.navbarVisiblity !== 'hidden');
467
- this.toggleDraggableAnnotations();
468
469
  focusContentEditable(this.activeElement);
469
470
  if (this.hasAnnotationBeenCreated) {
470
471
  this.attachNewAnnotation();
@@ -566,7 +567,6 @@ export class YooPhotoEditorComponent {
566
567
  this.blockMoves.emit(true);
567
568
  if (this.activeElement) {
568
569
  this.toggleShowNavbar(false);
569
- this.updateDraggableBoundings();
570
570
  this.bottomContainerElement.classList.remove('active');
571
571
  getActionButton().validate.classList.remove('active');
572
572
  getActionButton().delete.classList.add('active');
@@ -781,7 +781,6 @@ export class YooPhotoEditorComponent {
781
781
  const borderColor = this.isDotEditMode ? defaultAnnotationTextColor : 'none';
782
782
  if (this.isTextMode) {
783
783
  this.updateAnnotationStyle('textColor', color);
784
- // focusContentEditable(this.activeElement);
785
784
  }
786
785
  el && Object.assign(el.style, { borderColor, color, backgroundColor });
787
786
  this.updateAnnotationStyle('backgroundColor', backgroundColor);
@@ -881,18 +880,17 @@ export class YooPhotoEditorComponent {
881
880
  }
882
881
  createTextBox() {
883
882
  var _a, _b, _c, _d, _e;
883
+ const getPercentPosition = (bound) => {
884
+ return ((this.imageBounds[bound] / 2 - this.activeElement[`client${capitalize(bound)}`] / 2) / this.imageBounds[bound]) * 100;
885
+ };
884
886
  this.isTextCreateMode = false;
885
887
  this.hasAnnotationBeenCreated = true;
886
888
  this.annotations.push({
887
889
  ...createBaseAnnotation('text'),
888
890
  text: ((_a = this.activeElement) === null || _a === void 0 ? void 0 : _a.innerText) || '',
889
- _local: {
890
- transform: {
891
- current: {
892
- x: parseFloat(this.activeElement.style.left),
893
- y: parseFloat(this.activeElement.style.top)
894
- }
895
- }
891
+ coords: {
892
+ percentX: getPercentPosition('width'),
893
+ percentY: getPercentPosition('height')
896
894
  },
897
895
  styles: {
898
896
  fontSize: this.size || SLIDER_THRESHOLD.text.default,
@@ -1036,6 +1034,7 @@ export class YooPhotoEditorComponent {
1036
1034
  (_a = this.annotationElements) === null || _a === void 0 ? void 0 : _a.forEach(e => {
1037
1035
  if (e) {
1038
1036
  e.classList.remove('hidden');
1037
+ e.classList.toggle('draggable', enableDraggable);
1039
1038
  Draggable.get(e) ? Draggable.get(e)[enableDraggable ? 'enable' : 'disable']() : this.getDraggableActions(e)[enableDraggable ? 'enable' : 'disable']();
1040
1039
  //bypass fix gsap draggable auto-generating user-select on editing a focusing textbox
1041
1040
  ['user-select', '-webkit-user-select', '-moz-user-select'].forEach(us => e.style.removeProperty(us));
@@ -1211,8 +1210,8 @@ export class YooPhotoEditorComponent {
1211
1210
  return this.navbarVisiblity !== 'disabled' && !this.isPreview && h(Navbar, { visibility: this.navbarVisiblity, animated: this.mode !== this.lastMode, currentOptions: this.menuOptions.getOptions()[this.mode], onOptionClick: (ev, btnContent) => this.optionsClick(ev, btnContent) });
1212
1211
  }
1213
1212
  renderAnnotations() {
1214
- var _a;
1215
- return !this.isLoading && (this.displayAnnotations || !this.isReadonly) && (h("section", { class: "annotations", style: this.imageSizeStyle.resized, ref: el => this.annotationsContainerElement = el }, (_a = this.annotations) === null || _a === void 0 ? void 0 : _a.map(a => a && (a === null || a === void 0 ? void 0 : a.type) === 'dot' ? this.renderDot(a) : this.renderTextbox(a))));
1213
+ var _a, _b, _c;
1214
+ return !this.isLoading && ((_b = (_a = this.imageSizeStyle) === null || _a === void 0 ? void 0 : _a.resized) === null || _b === void 0 ? void 0 : _b.width) && (this.displayAnnotations || !this.isReadonly) && (h("section", { class: "annotations", style: this.imageSizeStyle.resized, ref: el => this.annotationsContainerElement = el }, (_c = this.annotations) === null || _c === void 0 ? void 0 : _c.map(a => (a === null || a === void 0 ? void 0 : a.type) === 'dot' ? this.renderDot(a) : this.renderTextbox(a))));
1216
1215
  }
1217
1216
  renderSrcCanvas() {
1218
1217
  return h("canvas", { id: "src", onClick: (ev) => ev.preventDefault(), ref: el => this.canvasSrcElement = el, ...this.computedImageSize });
@@ -315,8 +315,9 @@ function centerAnnotation(annotation, containerElement) {
315
315
  const imageBounding = containerElement.getBoundingClientRect();
316
316
  const activeElementBounding = element.getBoundingClientRect();
317
317
  const getAbsoluteCenter = (axis) => {
318
+ var _a;
318
319
  const isX = axis === 'x';
319
- return (getDraggable(element)[axis] +
320
+ return isFinite((_a = getDraggable(element)) === null || _a === void 0 ? void 0 : _a[axis]) && (getDraggable(element)[axis] +
320
321
  imageBounding[isX ? 'width' : 'height'] / 2 +
321
322
  imageBounding[axis] -
322
323
  (activeElementBounding[axis] + activeElementBounding[isX ? 'width' : 'height'] / 2));
@@ -2,7 +2,7 @@ import { r as registerInstance, j as createEvent, f as forceUpdate, h, i as Host
2
2
  import './index-ae75c8a9.js';
3
3
  import { a as isAnnotationValid, b as getElement, c as getAnnotationPositionStyle } from './annotations-helpers-5c6b2931.js';
4
4
  import { h as showImageCropper, b as getAppContext } from './common-helpers-0d2e02ce.js';
5
- import { g as getDotToolTipElement, a as getDotInnerElement, s as setDotIndexes, h as hideAllDotTooltips, c as createDot, b as showDotTooltip, d as hideAllUnFocusedTooltips, e as getAnnotation, f as formatAnnotationForExport, r as reorderDotIndexes, i as deleteDot, j as saveTooltipContent, k as deleteEmptyDots } from './draggable-dots-helpers-176a6be5.js';
5
+ import { g as getDotToolTipElement, a as getDotInnerElement, s as setDotIndexes, h as hideAllDotTooltips, c as createDot, b as showDotTooltip, d as hideAllUnFocusedTooltips, e as getAnnotation, f as formatAnnotationForExport, r as reorderDotIndexes, i as deleteDot, j as saveTooltipContent, k as deleteEmptyDots } from './draggable-dots-helpers-1673d7b0.js';
6
6
  import { am as isFile, bb as blobToBase64, aA as getUUID, x as debounce, aD as gsapSet, aC as gsapTo, bc as scaleUpAnimation, aB as Draggable, b4 as isTranslationKey, t as translate } from './overlays-ded00ddd.js';
7
7
  import './lodash-814bf2cd.js';
8
8
  import './index-ce250cb7.js';
@@ -2,10 +2,10 @@ import { h, r as registerInstance, j as createEvent, f as forceUpdate, i as Host
2
2
  import { cp as getContrastColorName, t as translate, m as isNativeMobile, eS as getTransformInfos, w as isWeb, N as closeModal, cn as setStatusBarDarkMode, S as ScreenOrientation, b8 as getMedia, L as cleanupWKWebViewFilePath, b9 as getImageSize, ba as getResizedImageSize, eT as getImageScaleFactor, J as getAsyncExtraData, ae as showAlert, aB as Draggable, aC as gsapTo, B as isIOS, ab as enableKeyboardResize, bc as scaleUpAnimation, e as getCssColor, aD as gsapSet, bd as getContrastColor, cW as showContextMenu, af as showActionSheet } from './overlays-ded00ddd.js';
3
3
  import { T as TapticEngine } from './index-2beb9cd0.js';
4
4
  import { r as resizeObserve } from './index-ae75c8a9.js';
5
- import { i as isFunction, z as isEqual, B as cloneDeep } from './lodash-814bf2cd.js';
5
+ import { i as isFunction, z as isEqual, B as cloneDeep, y as capitalize } from './lodash-814bf2cd.js';
6
6
  import { a as isAnnotationValid, d as isAnnotationDeleted, b as getElement, h as isAnnotationFocused, i as isAnnotationEmpty, j as isElementInsideContainer, e as getPointerCoordinates } from './annotations-helpers-5c6b2931.js';
7
7
  import { v as cloudinary } from './common-helpers-0d2e02ce.js';
8
- import { l as getAnnotationStyle, j as saveTooltipContent, B as BUTTONS_CONFIG, A as ANIMATION_DELAY, m as isCanvasBlank, n as getPredefinedTexts, o as getBoundingClient, g as getDotToolTipElement, a as getDotInnerElement, S as SLIDER_THRESHOLD, L as LOADING_DELAY, h as hideAllDotTooltips, p as prepareAnnotationsData, s as setDotIndexes, q as drawImageOnCanvas, t as focusAnnotation, e as getAnnotation, u as updateAnnotationLocal, I as INIT_COORDS, v as setAnnotationPositionToClosestEdge, w as getAnnotationDraggableBounds, x as getFormattedAnnotationSize, y as getAbsoluteCenter, z as getRelativeCenter, C as showPredefinedTextsDialog, c as createDot, D as DOT_RADIUS, E as createBaseAnnotation, F as removeLocalsFromAnnotations, G as EEditorActions, b as showDotTooltip, H as formatAnnotationsForExport, J as deCenterAnnotation } from './draggable-dots-helpers-176a6be5.js';
8
+ import { l as getAnnotationStyle, j as saveTooltipContent, B as BUTTONS_CONFIG, A as ANIMATION_DELAY, m as isCanvasBlank, n as getPredefinedTexts, o as getBoundingClient, g as getDotToolTipElement, a as getDotInnerElement, S as SLIDER_THRESHOLD, L as LOADING_DELAY, h as hideAllDotTooltips, p as prepareAnnotationsData, s as setDotIndexes, q as drawImageOnCanvas, t as focusAnnotation, e as getAnnotation, u as updateAnnotationLocal, I as INIT_COORDS, v as setAnnotationPositionToClosestEdge, w as getAnnotationDraggableBounds, x as getFormattedAnnotationSize, y as getAbsoluteCenter, z as getRelativeCenter, C as showPredefinedTextsDialog, c as createDot, D as DOT_RADIUS, E as createBaseAnnotation, F as removeLocalsFromAnnotations, G as EEditorActions, b as showDotTooltip, H as formatAnnotationsForExport, J as deCenterAnnotation } from './draggable-dots-helpers-1673d7b0.js';
9
9
  import { l as focusContentEditable } from './form-input-helpers-425e0818.js';
10
10
  import './index-ce250cb7.js';
11
11
  import './_commonjsHelpers-bda24d0a.js';
@@ -408,7 +408,7 @@ let YooPhotoEditorComponent = class {
408
408
  };
409
409
  }
410
410
  get imageSizeStyle() {
411
- const getSize = (type) => { var _a; return (_a = this.imageSize) === null || _a === void 0 ? void 0 : _a[type]; };
411
+ const getSize = (type) => this.imageSize[type];
412
412
  const getStyle = (type) => {
413
413
  var _a, _b;
414
414
  return ({
@@ -416,7 +416,7 @@ let YooPhotoEditorComponent = class {
416
416
  width: `${(_b = getSize(type)) === null || _b === void 0 ? void 0 : _b.width}px`
417
417
  });
418
418
  };
419
- return {
419
+ return this.imageSize && {
420
420
  natural: getStyle('natural'),
421
421
  resized: getStyle('resized')
422
422
  };
@@ -575,16 +575,18 @@ let YooPhotoEditorComponent = class {
575
575
  this.hasDoneBeenClicked = newValue === 'tools';
576
576
  this.toggleSaveButton();
577
577
  this.toggleColorSelector();
578
- this.toggleDraggableAnnotations();
579
578
  }
580
579
  }
580
+ componentDidRender() {
581
+ this.toggleDraggableAnnotations();
582
+ this.updateDraggableBoundings();
583
+ }
581
584
  disconnectedCallback() {
582
585
  this.toggleKeyboardListeners(false);
583
586
  !this.isPreview && setStatusBarDarkMode(false);
584
587
  }
585
588
  initEditor() {
586
589
  this.initResizeObserver();
587
- this.toggleDraggableAnnotations();
588
590
  this.toggleKeyboardListeners(true);
589
591
  !this.isPreview && setStatusBarDarkMode(true);
590
592
  this.savedAnnotationElements = cloneDeep(this.annotationElements);
@@ -633,7 +635,6 @@ let YooPhotoEditorComponent = class {
633
635
  if (!this.isReadonly) {
634
636
  this.showActiveTooltip();
635
637
  this.toggleShowNavbar(this.navbarVisiblity !== 'hidden');
636
- this.toggleDraggableAnnotations();
637
638
  focusContentEditable(this.activeElement);
638
639
  if (this.hasAnnotationBeenCreated) {
639
640
  this.attachNewAnnotation();
@@ -735,7 +736,6 @@ let YooPhotoEditorComponent = class {
735
736
  this.blockMoves.emit(true);
736
737
  if (this.activeElement) {
737
738
  this.toggleShowNavbar(false);
738
- this.updateDraggableBoundings();
739
739
  this.bottomContainerElement.classList.remove('active');
740
740
  getActionButton().validate.classList.remove('active');
741
741
  getActionButton().delete.classList.add('active');
@@ -950,7 +950,6 @@ let YooPhotoEditorComponent = class {
950
950
  const borderColor = this.isDotEditMode ? defaultAnnotationTextColor : 'none';
951
951
  if (this.isTextMode) {
952
952
  this.updateAnnotationStyle('textColor', color);
953
- // focusContentEditable(this.activeElement);
954
953
  }
955
954
  el && Object.assign(el.style, { borderColor, color, backgroundColor });
956
955
  this.updateAnnotationStyle('backgroundColor', backgroundColor);
@@ -1050,18 +1049,17 @@ let YooPhotoEditorComponent = class {
1050
1049
  }
1051
1050
  createTextBox() {
1052
1051
  var _a, _b, _c, _d, _e;
1052
+ const getPercentPosition = (bound) => {
1053
+ return ((this.imageBounds[bound] / 2 - this.activeElement[`client${capitalize(bound)}`] / 2) / this.imageBounds[bound]) * 100;
1054
+ };
1053
1055
  this.isTextCreateMode = false;
1054
1056
  this.hasAnnotationBeenCreated = true;
1055
1057
  this.annotations.push({
1056
1058
  ...createBaseAnnotation('text'),
1057
1059
  text: ((_a = this.activeElement) === null || _a === void 0 ? void 0 : _a.innerText) || '',
1058
- _local: {
1059
- transform: {
1060
- current: {
1061
- x: parseFloat(this.activeElement.style.left),
1062
- y: parseFloat(this.activeElement.style.top)
1063
- }
1064
- }
1060
+ coords: {
1061
+ percentX: getPercentPosition('width'),
1062
+ percentY: getPercentPosition('height')
1065
1063
  },
1066
1064
  styles: {
1067
1065
  fontSize: this.size || SLIDER_THRESHOLD.text.default,
@@ -1205,6 +1203,7 @@ let YooPhotoEditorComponent = class {
1205
1203
  (_a = this.annotationElements) === null || _a === void 0 ? void 0 : _a.forEach(e => {
1206
1204
  if (e) {
1207
1205
  e.classList.remove('hidden');
1206
+ e.classList.toggle('draggable', enableDraggable);
1208
1207
  Draggable.get(e) ? Draggable.get(e)[enableDraggable ? 'enable' : 'disable']() : this.getDraggableActions(e)[enableDraggable ? 'enable' : 'disable']();
1209
1208
  //bypass fix gsap draggable auto-generating user-select on editing a focusing textbox
1210
1209
  ['user-select', '-webkit-user-select', '-moz-user-select'].forEach(us => e.style.removeProperty(us));
@@ -1378,8 +1377,8 @@ let YooPhotoEditorComponent = class {
1378
1377
  return this.navbarVisiblity !== 'disabled' && !this.isPreview && h(Navbar, { visibility: this.navbarVisiblity, animated: this.mode !== this.lastMode, currentOptions: this.menuOptions.getOptions()[this.mode], onOptionClick: (ev, btnContent) => this.optionsClick(ev, btnContent) });
1379
1378
  }
1380
1379
  renderAnnotations() {
1381
- var _a;
1382
- return !this.isLoading && (this.displayAnnotations || !this.isReadonly) && (h("section", { class: "annotations", style: this.imageSizeStyle.resized, ref: el => this.annotationsContainerElement = el }, (_a = this.annotations) === null || _a === void 0 ? void 0 : _a.map(a => a && (a === null || a === void 0 ? void 0 : a.type) === 'dot' ? this.renderDot(a) : this.renderTextbox(a))));
1380
+ var _a, _b, _c;
1381
+ return !this.isLoading && ((_b = (_a = this.imageSizeStyle) === null || _a === void 0 ? void 0 : _a.resized) === null || _b === void 0 ? void 0 : _b.width) && (this.displayAnnotations || !this.isReadonly) && (h("section", { class: "annotations", style: this.imageSizeStyle.resized, ref: el => this.annotationsContainerElement = el }, (_c = this.annotations) === null || _c === void 0 ? void 0 : _c.map(a => (a === null || a === void 0 ? void 0 : a.type) === 'dot' ? this.renderDot(a) : this.renderTextbox(a))));
1383
1382
  }
1384
1383
  renderSrcCanvas() {
1385
1384
  return h("canvas", { id: "src", onClick: (ev) => ev.preventDefault(), ref: el => this.canvasSrcElement = el, ...this.computedImageSize });
@@ -315,8 +315,9 @@ function centerAnnotation(annotation, containerElement) {
315
315
  const imageBounding = containerElement.getBoundingClientRect();
316
316
  const activeElementBounding = element.getBoundingClientRect();
317
317
  const getAbsoluteCenter = (axis) => {
318
+ var _a;
318
319
  const isX = axis === 'x';
319
- return (getDraggable(element)[axis] +
320
+ return isFinite((_a = getDraggable(element)) === null || _a === void 0 ? void 0 : _a[axis]) && (getDraggable(element)[axis] +
320
321
  imageBounding[isX ? 'width' : 'height'] / 2 +
321
322
  imageBounding[axis] -
322
323
  (activeElementBounding[axis] + activeElementBounding[isX ? 'width' : 'height'] / 2));
@@ -2,7 +2,7 @@ import { r as registerInstance, j as createEvent, f as forceUpdate, h, i as Host
2
2
  import './index-ae75c8a9.js';
3
3
  import { a as isAnnotationValid, b as getElement, c as getAnnotationPositionStyle } from './annotations-helpers-5c6b2931.js';
4
4
  import { h as showImageCropper, b as getAppContext } from './common-helpers-0d2e02ce.js';
5
- import { g as getDotToolTipElement, a as getDotInnerElement, s as setDotIndexes, h as hideAllDotTooltips, c as createDot, b as showDotTooltip, d as hideAllUnFocusedTooltips, e as getAnnotation, f as formatAnnotationForExport, r as reorderDotIndexes, i as deleteDot, j as saveTooltipContent, k as deleteEmptyDots } from './draggable-dots-helpers-176a6be5.js';
5
+ import { g as getDotToolTipElement, a as getDotInnerElement, s as setDotIndexes, h as hideAllDotTooltips, c as createDot, b as showDotTooltip, d as hideAllUnFocusedTooltips, e as getAnnotation, f as formatAnnotationForExport, r as reorderDotIndexes, i as deleteDot, j as saveTooltipContent, k as deleteEmptyDots } from './draggable-dots-helpers-1673d7b0.js';
6
6
  import { am as isFile, bb as blobToBase64, aA as getUUID, x as debounce, aD as gsapSet, aC as gsapTo, bc as scaleUpAnimation, aB as Draggable, b4 as isTranslationKey, t as translate } from './overlays-ded00ddd.js';
7
7
  import './lodash-814bf2cd.js';
8
8
  import './index-ce250cb7.js';
@@ -2,10 +2,10 @@ import { h, r as registerInstance, j as createEvent, f as forceUpdate, i as Host
2
2
  import { cp as getContrastColorName, t as translate, m as isNativeMobile, eS as getTransformInfos, w as isWeb, N as closeModal, cn as setStatusBarDarkMode, S as ScreenOrientation, b8 as getMedia, L as cleanupWKWebViewFilePath, b9 as getImageSize, ba as getResizedImageSize, eT as getImageScaleFactor, J as getAsyncExtraData, ae as showAlert, aB as Draggable, aC as gsapTo, B as isIOS, ab as enableKeyboardResize, bc as scaleUpAnimation, e as getCssColor, aD as gsapSet, bd as getContrastColor, cW as showContextMenu, af as showActionSheet } from './overlays-ded00ddd.js';
3
3
  import { T as TapticEngine } from './index-2beb9cd0.js';
4
4
  import { r as resizeObserve } from './index-ae75c8a9.js';
5
- import { i as isFunction, z as isEqual, B as cloneDeep } from './lodash-814bf2cd.js';
5
+ import { i as isFunction, z as isEqual, B as cloneDeep, y as capitalize } from './lodash-814bf2cd.js';
6
6
  import { a as isAnnotationValid, d as isAnnotationDeleted, b as getElement, h as isAnnotationFocused, i as isAnnotationEmpty, j as isElementInsideContainer, e as getPointerCoordinates } from './annotations-helpers-5c6b2931.js';
7
7
  import { v as cloudinary } from './common-helpers-0d2e02ce.js';
8
- import { l as getAnnotationStyle, j as saveTooltipContent, B as BUTTONS_CONFIG, A as ANIMATION_DELAY, m as isCanvasBlank, n as getPredefinedTexts, o as getBoundingClient, g as getDotToolTipElement, a as getDotInnerElement, S as SLIDER_THRESHOLD, L as LOADING_DELAY, h as hideAllDotTooltips, p as prepareAnnotationsData, s as setDotIndexes, q as drawImageOnCanvas, t as focusAnnotation, e as getAnnotation, u as updateAnnotationLocal, I as INIT_COORDS, v as setAnnotationPositionToClosestEdge, w as getAnnotationDraggableBounds, x as getFormattedAnnotationSize, y as getAbsoluteCenter, z as getRelativeCenter, C as showPredefinedTextsDialog, c as createDot, D as DOT_RADIUS, E as createBaseAnnotation, F as removeLocalsFromAnnotations, G as EEditorActions, b as showDotTooltip, H as formatAnnotationsForExport, J as deCenterAnnotation } from './draggable-dots-helpers-176a6be5.js';
8
+ import { l as getAnnotationStyle, j as saveTooltipContent, B as BUTTONS_CONFIG, A as ANIMATION_DELAY, m as isCanvasBlank, n as getPredefinedTexts, o as getBoundingClient, g as getDotToolTipElement, a as getDotInnerElement, S as SLIDER_THRESHOLD, L as LOADING_DELAY, h as hideAllDotTooltips, p as prepareAnnotationsData, s as setDotIndexes, q as drawImageOnCanvas, t as focusAnnotation, e as getAnnotation, u as updateAnnotationLocal, I as INIT_COORDS, v as setAnnotationPositionToClosestEdge, w as getAnnotationDraggableBounds, x as getFormattedAnnotationSize, y as getAbsoluteCenter, z as getRelativeCenter, C as showPredefinedTextsDialog, c as createDot, D as DOT_RADIUS, E as createBaseAnnotation, F as removeLocalsFromAnnotations, G as EEditorActions, b as showDotTooltip, H as formatAnnotationsForExport, J as deCenterAnnotation } from './draggable-dots-helpers-1673d7b0.js';
9
9
  import { l as focusContentEditable } from './form-input-helpers-425e0818.js';
10
10
  import './index-ce250cb7.js';
11
11
  import './_commonjsHelpers-bda24d0a.js';
@@ -408,7 +408,7 @@ let YooPhotoEditorComponent = class {
408
408
  };
409
409
  }
410
410
  get imageSizeStyle() {
411
- const getSize = (type) => { var _a; return (_a = this.imageSize) === null || _a === void 0 ? void 0 : _a[type]; };
411
+ const getSize = (type) => this.imageSize[type];
412
412
  const getStyle = (type) => {
413
413
  var _a, _b;
414
414
  return ({
@@ -416,7 +416,7 @@ let YooPhotoEditorComponent = class {
416
416
  width: `${(_b = getSize(type)) === null || _b === void 0 ? void 0 : _b.width}px`
417
417
  });
418
418
  };
419
- return {
419
+ return this.imageSize && {
420
420
  natural: getStyle('natural'),
421
421
  resized: getStyle('resized')
422
422
  };
@@ -575,16 +575,18 @@ let YooPhotoEditorComponent = class {
575
575
  this.hasDoneBeenClicked = newValue === 'tools';
576
576
  this.toggleSaveButton();
577
577
  this.toggleColorSelector();
578
- this.toggleDraggableAnnotations();
579
578
  }
580
579
  }
580
+ componentDidRender() {
581
+ this.toggleDraggableAnnotations();
582
+ this.updateDraggableBoundings();
583
+ }
581
584
  disconnectedCallback() {
582
585
  this.toggleKeyboardListeners(false);
583
586
  !this.isPreview && setStatusBarDarkMode(false);
584
587
  }
585
588
  initEditor() {
586
589
  this.initResizeObserver();
587
- this.toggleDraggableAnnotations();
588
590
  this.toggleKeyboardListeners(true);
589
591
  !this.isPreview && setStatusBarDarkMode(true);
590
592
  this.savedAnnotationElements = cloneDeep(this.annotationElements);
@@ -633,7 +635,6 @@ let YooPhotoEditorComponent = class {
633
635
  if (!this.isReadonly) {
634
636
  this.showActiveTooltip();
635
637
  this.toggleShowNavbar(this.navbarVisiblity !== 'hidden');
636
- this.toggleDraggableAnnotations();
637
638
  focusContentEditable(this.activeElement);
638
639
  if (this.hasAnnotationBeenCreated) {
639
640
  this.attachNewAnnotation();
@@ -735,7 +736,6 @@ let YooPhotoEditorComponent = class {
735
736
  this.blockMoves.emit(true);
736
737
  if (this.activeElement) {
737
738
  this.toggleShowNavbar(false);
738
- this.updateDraggableBoundings();
739
739
  this.bottomContainerElement.classList.remove('active');
740
740
  getActionButton().validate.classList.remove('active');
741
741
  getActionButton().delete.classList.add('active');
@@ -950,7 +950,6 @@ let YooPhotoEditorComponent = class {
950
950
  const borderColor = this.isDotEditMode ? defaultAnnotationTextColor : 'none';
951
951
  if (this.isTextMode) {
952
952
  this.updateAnnotationStyle('textColor', color);
953
- // focusContentEditable(this.activeElement);
954
953
  }
955
954
  el && Object.assign(el.style, { borderColor, color, backgroundColor });
956
955
  this.updateAnnotationStyle('backgroundColor', backgroundColor);
@@ -1050,18 +1049,17 @@ let YooPhotoEditorComponent = class {
1050
1049
  }
1051
1050
  createTextBox() {
1052
1051
  var _a, _b, _c, _d, _e;
1052
+ const getPercentPosition = (bound) => {
1053
+ return ((this.imageBounds[bound] / 2 - this.activeElement[`client${capitalize(bound)}`] / 2) / this.imageBounds[bound]) * 100;
1054
+ };
1053
1055
  this.isTextCreateMode = false;
1054
1056
  this.hasAnnotationBeenCreated = true;
1055
1057
  this.annotations.push({
1056
1058
  ...createBaseAnnotation('text'),
1057
1059
  text: ((_a = this.activeElement) === null || _a === void 0 ? void 0 : _a.innerText) || '',
1058
- _local: {
1059
- transform: {
1060
- current: {
1061
- x: parseFloat(this.activeElement.style.left),
1062
- y: parseFloat(this.activeElement.style.top)
1063
- }
1064
- }
1060
+ coords: {
1061
+ percentX: getPercentPosition('width'),
1062
+ percentY: getPercentPosition('height')
1065
1063
  },
1066
1064
  styles: {
1067
1065
  fontSize: this.size || SLIDER_THRESHOLD.text.default,
@@ -1205,6 +1203,7 @@ let YooPhotoEditorComponent = class {
1205
1203
  (_a = this.annotationElements) === null || _a === void 0 ? void 0 : _a.forEach(e => {
1206
1204
  if (e) {
1207
1205
  e.classList.remove('hidden');
1206
+ e.classList.toggle('draggable', enableDraggable);
1208
1207
  Draggable.get(e) ? Draggable.get(e)[enableDraggable ? 'enable' : 'disable']() : this.getDraggableActions(e)[enableDraggable ? 'enable' : 'disable']();
1209
1208
  //bypass fix gsap draggable auto-generating user-select on editing a focusing textbox
1210
1209
  ['user-select', '-webkit-user-select', '-moz-user-select'].forEach(us => e.style.removeProperty(us));
@@ -1378,8 +1377,8 @@ let YooPhotoEditorComponent = class {
1378
1377
  return this.navbarVisiblity !== 'disabled' && !this.isPreview && h(Navbar, { visibility: this.navbarVisiblity, animated: this.mode !== this.lastMode, currentOptions: this.menuOptions.getOptions()[this.mode], onOptionClick: (ev, btnContent) => this.optionsClick(ev, btnContent) });
1379
1378
  }
1380
1379
  renderAnnotations() {
1381
- var _a;
1382
- return !this.isLoading && (this.displayAnnotations || !this.isReadonly) && (h("section", { class: "annotations", style: this.imageSizeStyle.resized, ref: el => this.annotationsContainerElement = el }, (_a = this.annotations) === null || _a === void 0 ? void 0 : _a.map(a => a && (a === null || a === void 0 ? void 0 : a.type) === 'dot' ? this.renderDot(a) : this.renderTextbox(a))));
1380
+ var _a, _b, _c;
1381
+ return !this.isLoading && ((_b = (_a = this.imageSizeStyle) === null || _a === void 0 ? void 0 : _a.resized) === null || _b === void 0 ? void 0 : _b.width) && (this.displayAnnotations || !this.isReadonly) && (h("section", { class: "annotations", style: this.imageSizeStyle.resized, ref: el => this.annotationsContainerElement = el }, (_c = this.annotations) === null || _c === void 0 ? void 0 : _c.map(a => (a === null || a === void 0 ? void 0 : a.type) === 'dot' ? this.renderDot(a) : this.renderTextbox(a))));
1383
1382
  }
1384
1383
  renderSrcCanvas() {
1385
1384
  return h("canvas", { id: "src", onClick: (ev) => ev.preventDefault(), ref: el => this.canvasSrcElement = el, ...this.computedImageSize });
@@ -231,6 +231,7 @@ export declare class YooPhotoEditorComponent implements ComponentInterface {
231
231
  componentDidLoad(): void;
232
232
  componentDidUpdate(): void;
233
233
  componentShouldUpdate(...args: any[]): void;
234
+ componentDidRender(): void;
234
235
  disconnectedCallback(): void;
235
236
  private initEditor;
236
237
  private prepareSrc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoobic/yobi",
3
- "version": "8.1.0-30",
3
+ "version": "8.1.0-31",
4
4
  "description": "Yobi - Yoobic Design System",
5
5
  "module": "dist/index.js",
6
6
  "main": "dist/index.cjs.js",