bfg-common 1.4.418 → 1.4.420

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.
@@ -70,6 +70,7 @@
70
70
  type="default"
71
71
  variant="outline"
72
72
  class="btn marker"
73
+ :class="drawerMarker === 'marker' && 'active'"
73
74
  @click="onUseRedMarker"
74
75
  >
75
76
  <ui-icon
@@ -87,6 +88,7 @@
87
88
  type="default"
88
89
  variant="outline"
89
90
  class="btn eraser"
91
+ :class="drawerMarker === 'eraser' && 'active'"
90
92
  @click="onUseGrayEraser"
91
93
  >
92
94
  <ui-icon
@@ -203,13 +205,14 @@ const optionsModel = defineModel<UI_I_FeedbackCanvasOptions>({ required: true })
203
205
 
204
206
  const localization = computed<UI_I_Localization>(() => useLocal())
205
207
 
208
+ const drawerMarker = ref<'marker' | 'eraser' | null>(null)
206
209
  const isFileLoad = ref(null)
207
210
  const feedbackImgWrap = ref()
208
211
  const feedbackImg = ref()
209
212
  const memoryParentModalDialog = ref<string>('')
210
213
  const memoryParentMain = ref<string>('')
211
214
 
212
- const drawingArray: any = []
215
+ let drawingArray: any = []
213
216
  const indexArray = ref<number>(0) // index of feedbackImg itself
214
217
  let isDrawing = false
215
218
  let startDrawingX: number | null = null
@@ -279,8 +282,7 @@ const onUploadFile = (): void => {
279
282
  feedbackImg.value.width = img.width
280
283
  feedbackImg.value.height = img.height
281
284
 
282
- feedbackImg.value.style.width = '500px'
283
- feedbackImg.value.style.height = img.height / (img.width / 500) + 'px'
285
+ updateFeedbackImageDimensions()
284
286
 
285
287
  context.drawImage(img, 0, 0, img.width, img.height)
286
288
  drawingArray.length = 0
@@ -389,24 +391,13 @@ const onRemoveScreenshot = (): void => {
389
391
  // emits('screen-shot', value)
390
392
  clearAll()
391
393
  }
392
-
393
- const clearAll = (): void => {
394
- const context = feedbackImg.value.getContext('2d')
395
- // drawColor = ''
396
- // drawWidth = ''
397
- if (indexArray.value <= 0) return
398
- while (indexArray.value > 0) {
399
- drawingArray.pop()
400
- indexArray.value -= 1
401
- context.putImageData(drawingArray[indexArray.value], 0, 0)
402
- }
403
- }
404
-
405
394
  const onUseRedMarker = (): void => {
395
+ drawerMarker.value = 'marker'
406
396
  drawColor = '#f76945'
407
397
  drawWidth = '5'
408
398
  }
409
399
  const onUseGrayEraser = (): void => {
400
+ drawerMarker.value = 'eraser'
410
401
  drawColor = 'lightgray'
411
402
  drawWidth = '14'
412
403
  }
@@ -414,6 +405,7 @@ const onUseGrayEraser = (): void => {
414
405
  const onUndoLast = (): void => {
415
406
  drawColor = ''
416
407
  drawWidth = ''
408
+ drawerMarker.value = null
417
409
  const context = feedbackImg.value.getContext('2d')
418
410
  if (indexArray.value > 0) {
419
411
  indexArray.value -= 1
@@ -421,6 +413,18 @@ const onUndoLast = (): void => {
421
413
  context.putImageData(drawingArray[indexArray.value], 0, 0)
422
414
  }
423
415
  }
416
+ const clearAll = (): void => {
417
+ const context = feedbackImg.value.getContext('2d')
418
+ drawColor = ''
419
+ drawWidth = ''
420
+ drawerMarker.value = null
421
+ if (indexArray.value <= 0) return
422
+ while (indexArray.value > 0) {
423
+ drawingArray.pop()
424
+ indexArray.value -= 1
425
+ context.putImageData(drawingArray[indexArray.value], 0, 0)
426
+ }
427
+ }
424
428
 
425
429
  onMounted(() => {
426
430
  feedbackImg.value.addEventListener('touchstart', start, false)
@@ -448,13 +452,25 @@ const onAnnotateImage = (): void => {
448
452
 
449
453
  optionsModel.value.isAnnotateImage = true
450
454
  }
455
+
456
+ const updateFeedbackImageDimensions = (): void => {
457
+ if (feedbackImg.value) {
458
+ feedbackImg.value.style.width = '500px'
459
+ feedbackImg.value.style.height =
460
+ feedbackImg.value.height / (feedbackImg.value.width / 500) + 'px'
461
+ }
462
+ }
463
+ const resetDrawingState = (): void => {
464
+ drawingArray = [drawingArray.at(-1)]
465
+ indexArray.value = 0
466
+ }
467
+
451
468
  watch(
452
469
  optionsModel,
453
470
  (newValue: UI_I_FeedbackCanvasOptions) => {
454
- if (!newValue.isAnnotateImage && feedbackImg.value) {
455
- feedbackImg.value.style.width = '500px'
456
- feedbackImg.value.style.height =
457
- feedbackImg.value.height / (feedbackImg.value.width / 500) + 'px'
471
+ if (!newValue.isAnnotateImage) {
472
+ updateFeedbackImageDimensions()
473
+ resetDrawingState()
458
474
  }
459
475
  },
460
476
  { deep: true, immediate: true }
@@ -481,16 +497,12 @@ watch(
481
497
  }
482
498
  }
483
499
  .drawer-btn-container {
500
+ @include flex($align: center, $just: space-between);
484
501
  margin-bottom: 12px;
485
502
  & > div {
486
- display: flex;
487
- align-items: center;
488
- justify-content: space-between;
503
+ @include flex($align: center, $just: space-between);
489
504
  gap: 15px;
490
505
  }
491
- display: flex;
492
- align-items: center;
493
- justify-content: space-between;
494
506
 
495
507
  .ui-btn {
496
508
  width: initial;
@@ -498,6 +510,11 @@ watch(
498
510
  &.clear-all {
499
511
  color: #ea3223;
500
512
  }
513
+
514
+ &.active {
515
+ border: 1.4px solid var(--feedback-tab-active-text-color);
516
+ color: var(--feedback-tab-active-text-color);
517
+ }
501
518
  }
502
519
  }
503
520
 
@@ -532,8 +549,7 @@ watch(
532
549
  opacity: 0;
533
550
 
534
551
  & > div {
535
- display: flex;
536
- align-items: center;
552
+ @include flex($align: center);
537
553
  gap: 12px;
538
554
  .ui-btn {
539
555
  width: initial;
@@ -555,9 +571,7 @@ watch(
555
571
  }
556
572
 
557
573
  &:hover:not(&.annotate) &__backdrop {
558
- display: flex;
559
- align-items: center;
560
- justify-content: center;
574
+ @include flex($align: center, $just: center);
561
575
  opacity: 1;
562
576
  }
563
577
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.418",
4
+ "version": "1.4.420",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",