112
112
@mousedown =" selectPage(pIndex)"
113
113
@touchstart =" selectPage(pIndex)" >
114
114
<div style =" display : inline-block ;"
115
- class =" relative shadow-lg"
115
+ class =" relative shadow-lg page "
116
116
:class =" [pIndex === selectedPageIndex ?'shadowOutline':'']" >
117
117
<PDFPage :ref =" `page${pIndex}`"
118
118
:scale =" scale"
127
127
<slot name =" custom"
128
128
:object =" object"
129
129
:pagesScale =" pagesScale[pIndex]"
130
- :canvas-width =" object.canvasWidth"
131
- :canvas-height =" object.canvasHeight"
132
130
@onUpdate =" updateObject(object.id, $event)"
133
131
@onDelete =" deleteObject(object.id)" />
134
132
</div >
143
141
:origin-width =" object.originWidth"
144
142
:origin-height =" object.originHeight"
145
143
:page-scale =" pagesScale[pIndex]"
146
- :canvas-width =" object.canvasWidth"
147
- :canvas-height =" object.canvasHeight"
148
144
@onUpdate =" updateObject(object.id, $event)"
149
145
@onDelete =" deleteObject(object.id)" />
150
146
</div >
163
159
:font-family =" object.fontFamily"
164
160
:current-page =" object.currentPage"
165
161
:page-scale =" pagesScale[pIndex]"
166
- :canvas-width =" object.canvasWidth"
167
- :canvas-height =" object.canvasHeight"
168
162
@onUpdate =" updateObject(object.id, $event)"
169
163
@onDelete =" deleteObject(object.id)"
170
164
@onSelectFont =" selectFontFamily" />
178
172
:origin-width =" object.originWidth"
179
173
:origin-height =" object.originHeight"
180
174
:page-scale =" pagesScale[pIndex]"
181
- :canvas-width =" object.canvasWidth"
182
- :canvas-height =" object.canvasHeight"
183
175
@onUpdate =" updateObject(object.id, $event)"
184
176
@onDelete =" deleteObject(object.id)" />
185
177
</div >
@@ -520,15 +512,17 @@ export default {
520
512
measurement: [],
521
513
}
522
514
// Wait until all pages have been read
523
- const pages = await Promise .all (this .pages );
524
- pages .forEach ((page ) => {
525
- const measurement = page .getViewport ().viewBox
526
- data .measurement [page .pageNumber ] = {
527
- width: measurement[2 ],
528
- height: measurement[3 ],
529
- }
530
- })
531
- this .$emit (' pdf-editor:end-init' , data)
515
+ Promise .all (this .pages )
516
+ .then (pages => {
517
+ pages .forEach ((page ) => {
518
+ const measurement = page .getViewport ().viewBox
519
+ data .measurement [page .pageNumber ] = {
520
+ width: measurement[2 ],
521
+ height: measurement[3 ],
522
+ }
523
+ })
524
+ this .$emit (' pdf-editor:end-init' , data)
525
+ })
532
526
}
533
527
} catch (e) {
534
528
console .log (' Failed to add pdf.' )
@@ -555,20 +549,13 @@ export default {
555
549
const id = this .genID ()
556
550
const { width , height } = img
557
551
558
- const { canvasWidth , canvasHeight }
559
- = this .$refs [
560
- ` page${ this .selectedPageIndex } `
561
- ][0 ].getCanvasMeasurement ()
562
-
563
552
const object = {
564
553
id,
565
554
type: ' image' ,
566
555
width: width * sizeNarrow,
567
556
height: height * sizeNarrow,
568
557
originWidth: width,
569
558
originHeight: height,
570
- canvasWidth,
571
- canvasHeight,
572
559
x,
573
560
y,
574
561
isSealImage,
@@ -590,20 +577,13 @@ export default {
590
577
const id = this .genID ()
591
578
fetchFont (this .currentFont )
592
579
593
- const { canvasWidth , canvasHeight }
594
- = this .$refs [
595
- ` page${ this .selectedPageIndex } `
596
- ][0 ].getCanvasMeasurement ()
597
-
598
580
const object = {
599
581
id,
600
582
text,
601
583
type: ' text' ,
602
584
size: this .textDefaultSize ,
603
585
lineHeight: 1.4 ,
604
586
fontFamily: this .currentFont ,
605
- canvasWidth,
606
- canvasHeight,
607
587
x,
608
588
y,
609
589
currentPage,
@@ -620,11 +600,6 @@ export default {
620
600
addDrawing (originWidth , originHeight , path , scale = 1 ) {
621
601
const id = this .genID ()
622
602
623
- const { canvasWidth , canvasHeight }
624
- = this .$refs [
625
- ` page${ this .selectedPageIndex } `
626
- ][0 ].getCanvasMeasurement ()
627
-
628
603
const object = {
629
604
id,
630
605
path,
@@ -635,8 +610,6 @@ export default {
635
610
originHeight,
636
611
width: originWidth * scale,
637
612
height: originHeight * scale,
638
- canvasWidth,
639
- canvasHeight,
640
613
scale,
641
614
}
642
615
this .addObject (object)
0 commit comments