bfg-common 1.4.417 → 1.4.419

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.
@@ -197,19 +197,20 @@ import type { UI_I_Localization } from '~/lib/models/interfaces'
197
197
  import type { UI_I_FeedbackCanvasOptions } from '~/components/common/layout/theHeader/feedback/new/lib/models/interfaces'
198
198
 
199
199
  const optionsModel = defineModel<UI_I_FeedbackCanvasOptions>({ required: true })
200
- const emits = defineEmits<{
201
- (event: 'screen-shot', value: any): void
202
- }>()
200
+ // const emits = defineEmits<{
201
+ // (event: 'screen-shot', value: any): void
202
+ // }>()
203
203
 
204
204
  const localization = computed<UI_I_Localization>(() => useLocal())
205
205
 
206
+ const drawerMarker = ref<'marker' | 'eraser' | null>(null)
206
207
  const isFileLoad = ref(null)
207
208
  const feedbackImgWrap = ref()
208
209
  const feedbackImg = ref()
209
210
  const memoryParentModalDialog = ref<string>('')
210
211
  const memoryParentMain = ref<string>('')
211
212
 
212
- const drawingArray: any = []
213
+ let drawingArray: any = []
213
214
  const indexArray = ref<number>(0) // index of feedbackImg itself
214
215
  let isDrawing = false
215
216
  let startDrawingX: number | null = null
@@ -221,11 +222,11 @@ const isDisabledButton = computed<boolean>(() => indexArray.value === 0)
221
222
 
222
223
  const onTakeScreenshot = (): void => {
223
224
  optionsModel.value.hasTakeScreenshot = true
224
- const value = {
225
- width: window.outerWidth + 'px',
226
- }
225
+ // const value = {
226
+ // width: window.outerWidth + 'px',
227
+ // }
227
228
 
228
- emits('screen-shot', value)
229
+ // emits('screen-shot', value)
229
230
  const parentMain = document.getElementById('feedbackId')
230
231
  const parentModalDialog = document.getElementById('feedback-modal-dialog-Id')
231
232
  if (!parentMain || !parentModalDialog) return
@@ -278,6 +279,10 @@ const onUploadFile = (): void => {
278
279
  img.onload = (): void => {
279
280
  feedbackImg.value.width = img.width
280
281
  feedbackImg.value.height = img.height
282
+
283
+ feedbackImg.value.style.width = '500px'
284
+ feedbackImg.value.style.height = img.height / (img.width / 500) + 'px'
285
+
281
286
  context.drawImage(img, 0, 0, img.width, img.height)
282
287
  drawingArray.length = 0
283
288
  indexArray.value = 0
@@ -289,10 +294,10 @@ const onUploadFile = (): void => {
289
294
  feedbackImg.value.height
290
295
  )
291
296
  )
292
- const value = {
293
- width: window.outerWidth + 'px',
294
- }
295
- emits('screen-shot', value)
297
+ // const value = {
298
+ // width: window.outerWidth + 'px',
299
+ // }
300
+ // emits('screen-shot', value)
296
301
  const parentMain = document.getElementById('feedbackId')
297
302
  const parentModalDialog = document.getElementById(
298
303
  'feedback-modal-dialog-Id'
@@ -379,30 +384,19 @@ const onRemoveScreenshot = (): void => {
379
384
  feedbackImg.value.height = 0
380
385
  feedbackImgWrap.value.style.width = 0 + 'px'
381
386
  feedbackImgWrap.value.style.height = 0 + 'px'
382
- const value = {
383
- width: memoryParentModalDialog.value,
384
- }
385
- emits('screen-shot', value)
387
+ // const value = {
388
+ // width: memoryParentModalDialog.value,
389
+ // }
390
+ // emits('screen-shot', value)
386
391
  clearAll()
387
392
  }
388
-
389
- const clearAll = (): void => {
390
- const context = feedbackImg.value.getContext('2d')
391
- // drawColor = ''
392
- // drawWidth = ''
393
- if (indexArray.value <= 0) return
394
- while (indexArray.value > 0) {
395
- drawingArray.pop()
396
- indexArray.value -= 1
397
- context.putImageData(drawingArray[indexArray.value], 0, 0)
398
- }
399
- }
400
-
401
393
  const onUseRedMarker = (): void => {
394
+ drawerMarker.value = 'marker'
402
395
  drawColor = '#f76945'
403
396
  drawWidth = '5'
404
397
  }
405
398
  const onUseGrayEraser = (): void => {
399
+ drawerMarker.value = 'eraser'
406
400
  drawColor = 'lightgray'
407
401
  drawWidth = '14'
408
402
  }
@@ -410,6 +404,7 @@ const onUseGrayEraser = (): void => {
410
404
  const onUndoLast = (): void => {
411
405
  drawColor = ''
412
406
  drawWidth = ''
407
+ drawerMarker.value = null
413
408
  const context = feedbackImg.value.getContext('2d')
414
409
  if (indexArray.value > 0) {
415
410
  indexArray.value -= 1
@@ -417,6 +412,18 @@ const onUndoLast = (): void => {
417
412
  context.putImageData(drawingArray[indexArray.value], 0, 0)
418
413
  }
419
414
  }
415
+ const clearAll = (): void => {
416
+ const context = feedbackImg.value.getContext('2d')
417
+ drawColor = ''
418
+ drawWidth = ''
419
+ drawerMarker.value = null
420
+ if (indexArray.value <= 0) return
421
+ while (indexArray.value > 0) {
422
+ drawingArray.pop()
423
+ indexArray.value -= 1
424
+ context.putImageData(drawingArray[indexArray.value], 0, 0)
425
+ }
426
+ }
420
427
 
421
428
  onMounted(() => {
422
429
  feedbackImg.value.addEventListener('touchstart', start, false)
@@ -439,8 +446,34 @@ onBeforeUnmount(() => {
439
446
  feedbackImg.value.removeEventListener('mouseout', stop, false)
440
447
  })
441
448
  const onAnnotateImage = (): void => {
449
+ feedbackImg.value.style.width = feedbackImg.value.width + 'px'
450
+ feedbackImg.value.style.height = feedbackImg.value.height + 'px'
451
+
442
452
  optionsModel.value.isAnnotateImage = true
443
453
  }
454
+
455
+ const updateFeedbackImageDimensions = (): void => {
456
+ if (feedbackImg.value) {
457
+ feedbackImg.value.style.width = '500px'
458
+ feedbackImg.value.style.height =
459
+ feedbackImg.value.height / (feedbackImg.value.width / 500) + 'px'
460
+ }
461
+ }
462
+ const resetDrawingState = (): void => {
463
+ drawingArray = [drawingArray.at(-1)]
464
+ indexArray.value = 0
465
+ }
466
+
467
+ watch(
468
+ optionsModel,
469
+ (newValue: UI_I_FeedbackCanvasOptions) => {
470
+ if (!newValue.isAnnotateImage) {
471
+ updateFeedbackImageDimensions()
472
+ resetDrawingState()
473
+ }
474
+ },
475
+ { deep: true, immediate: true }
476
+ )
444
477
  </script>
445
478
 
446
479
  <style lang="scss" scoped>
@@ -463,16 +496,12 @@ const onAnnotateImage = (): void => {
463
496
  }
464
497
  }
465
498
  .drawer-btn-container {
499
+ @include flex($align: center, $just: space-between);
466
500
  margin-bottom: 12px;
467
501
  & > div {
468
- display: flex;
469
- align-items: center;
470
- justify-content: space-between;
502
+ @include flex($align: center, $just: space-between);
471
503
  gap: 15px;
472
504
  }
473
- display: flex;
474
- align-items: center;
475
- justify-content: space-between;
476
505
 
477
506
  .ui-btn {
478
507
  width: initial;
@@ -480,6 +509,11 @@ const onAnnotateImage = (): void => {
480
509
  &.clear-all {
481
510
  color: #ea3223;
482
511
  }
512
+
513
+ &.active {
514
+ border: 1.4px solid var(--feedback-tab-active-text-color);
515
+ color: var(--feedback-tab-active-text-color);
516
+ }
483
517
  }
484
518
  }
485
519
 
@@ -494,6 +528,7 @@ const onAnnotateImage = (): void => {
494
528
  &.annotate {
495
529
  width: 100%;
496
530
  height: 460px;
531
+ overflow: auto;
497
532
  }
498
533
  &.disabled {
499
534
  display: none;
@@ -513,8 +548,7 @@ const onAnnotateImage = (): void => {
513
548
  opacity: 0;
514
549
 
515
550
  & > div {
516
- display: flex;
517
- align-items: center;
551
+ @include flex($align: center);
518
552
  gap: 12px;
519
553
  .ui-btn {
520
554
  width: initial;
@@ -536,9 +570,7 @@ const onAnnotateImage = (): void => {
536
570
  }
537
571
 
538
572
  &:hover:not(&.annotate) &__backdrop {
539
- display: flex;
540
- align-items: center;
541
- justify-content: center;
573
+ @include flex($align: center, $just: center);
542
574
  opacity: 1;
543
575
  }
544
576
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.417",
4
+ "version": "1.4.419",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",