bfg-common 1.4.418 → 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.
@@ -203,13 +203,14 @@ const optionsModel = defineModel<UI_I_FeedbackCanvasOptions>({ required: true })
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
@@ -389,24 +390,13 @@ const onRemoveScreenshot = (): void => {
389
390
  // emits('screen-shot', value)
390
391
  clearAll()
391
392
  }
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
393
  const onUseRedMarker = (): void => {
394
+ drawerMarker.value = 'marker'
406
395
  drawColor = '#f76945'
407
396
  drawWidth = '5'
408
397
  }
409
398
  const onUseGrayEraser = (): void => {
399
+ drawerMarker.value = 'eraser'
410
400
  drawColor = 'lightgray'
411
401
  drawWidth = '14'
412
402
  }
@@ -414,6 +404,7 @@ const onUseGrayEraser = (): void => {
414
404
  const onUndoLast = (): void => {
415
405
  drawColor = ''
416
406
  drawWidth = ''
407
+ drawerMarker.value = null
417
408
  const context = feedbackImg.value.getContext('2d')
418
409
  if (indexArray.value > 0) {
419
410
  indexArray.value -= 1
@@ -421,6 +412,18 @@ const onUndoLast = (): void => {
421
412
  context.putImageData(drawingArray[indexArray.value], 0, 0)
422
413
  }
423
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
+ }
424
427
 
425
428
  onMounted(() => {
426
429
  feedbackImg.value.addEventListener('touchstart', start, false)
@@ -448,13 +451,25 @@ const onAnnotateImage = (): void => {
448
451
 
449
452
  optionsModel.value.isAnnotateImage = true
450
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
+
451
467
  watch(
452
468
  optionsModel,
453
469
  (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'
470
+ if (!newValue.isAnnotateImage) {
471
+ updateFeedbackImageDimensions()
472
+ resetDrawingState()
458
473
  }
459
474
  },
460
475
  { deep: true, immediate: true }
@@ -481,16 +496,12 @@ watch(
481
496
  }
482
497
  }
483
498
  .drawer-btn-container {
499
+ @include flex($align: center, $just: space-between);
484
500
  margin-bottom: 12px;
485
501
  & > div {
486
- display: flex;
487
- align-items: center;
488
- justify-content: space-between;
502
+ @include flex($align: center, $just: space-between);
489
503
  gap: 15px;
490
504
  }
491
- display: flex;
492
- align-items: center;
493
- justify-content: space-between;
494
505
 
495
506
  .ui-btn {
496
507
  width: initial;
@@ -498,6 +509,11 @@ watch(
498
509
  &.clear-all {
499
510
  color: #ea3223;
500
511
  }
512
+
513
+ &.active {
514
+ border: 1.4px solid var(--feedback-tab-active-text-color);
515
+ color: var(--feedback-tab-active-text-color);
516
+ }
501
517
  }
502
518
  }
503
519
 
@@ -532,8 +548,7 @@ watch(
532
548
  opacity: 0;
533
549
 
534
550
  & > div {
535
- display: flex;
536
- align-items: center;
551
+ @include flex($align: center);
537
552
  gap: 12px;
538
553
  .ui-btn {
539
554
  width: initial;
@@ -555,9 +570,7 @@ watch(
555
570
  }
556
571
 
557
572
  &:hover:not(&.annotate) &__backdrop {
558
- display: flex;
559
- align-items: center;
560
- justify-content: center;
573
+ @include flex($align: center, $just: center);
561
574
  opacity: 1;
562
575
  }
563
576
  }
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.419",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",