Skip to content

Commit 09a760f

Browse files
committed
fix: get width and height of text item
The size of element could be get from div wrapper Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent 15d8379 commit 09a760f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Components/TextItem.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ export default {
164164
// editable: null,
165165
dx: 0,
166166
dy: 0,
167+
width: 0,
168+
height: 0,
167169
operation: '',
168170
size_: this.size,
169171
lineHeight_: this.lineHeight,
@@ -233,6 +235,8 @@ export default {
233235
this.operation = ''
234236
},
235237
handlePanStart(event) {
238+
this.width = this.$refs.editable.offsetWidth
239+
this.height = this.$refs.editable.offsetHeight
236240
let coordinate
237241
if (event.type === 'mousedown') {
238242
coordinate = this.handleMousedown(event)

src/VuePdfEditor.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@
151151
:text="object.text"
152152
:x="object.x"
153153
:y="object.y"
154+
:width="object.width"
155+
:height="object.height"
154156
:show-line-size-select="showLineSizeSelect"
155157
:show-font-size-select="showFontSizeSelect"
156158
:show-font-select="showFontSelect"
@@ -595,7 +597,6 @@ export default {
595597
text,
596598
type: 'text',
597599
size: this.textDefaultSize,
598-
width: 0, // recalculate after editing
599600
lineHeight: 1.4,
600601
fontFamily: this.currentFont,
601602
pageWidth: this.pageSizes[currentPage + 1].width,

0 commit comments

Comments
 (0)