@libresign/pdf-elements 0.2.4 → 0.3.0
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.
- package/README.md +1 -1
- package/dist/pdf-elements.common.js +25126 -24680
- package/dist/pdf-elements.common.js.map +1 -1
- package/dist/pdf-elements.css +1 -1
- package/dist/pdf-elements.umd.js +25126 -24680
- package/dist/pdf-elements.umd.js.map +1 -1
- package/dist/pdf-elements.umd.min.js +2 -2
- package/dist/pdf-elements.umd.min.js.map +1 -1
- package/package.json +1 -2
- package/src/components/DraggableElement.vue +29 -5
- package/src/components/PDFElements.vue +389 -173
- package/src/components/PDFPage.vue +31 -8
- package/src/index.js +0 -5
- package/src/utils/geometry.js +20 -0
- package/src/utils/measurements.js +16 -0
- package/src/utils/objectStore.js +35 -0
- package/src/utils/pageBounds.js +13 -0
- package/src/utils/zoom.js +8 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libresign/pdf-elements",
|
|
3
3
|
"description": "PDF viewer with draggable and resizable element overlays for Vue 2",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"author": "LibreCode <contact@librecode.coop>",
|
|
6
6
|
"private": false,
|
|
7
7
|
"main": "dist/pdf-elements.umd.js",
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
"lint:fix": "vue-cli-service lint"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"debounce": "^3.0.0",
|
|
35
34
|
"pdfjs-dist": "^5.4.530",
|
|
36
35
|
"vue": "^2.7.16"
|
|
37
36
|
},
|
|
@@ -10,7 +10,12 @@ SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
10
10
|
class="actions-toolbar"
|
|
11
11
|
:style="toolbarStyle"
|
|
12
12
|
>
|
|
13
|
-
<slot name="actions" :object="object" :onDelete="onDelete">
|
|
13
|
+
<slot name="actions" :object="object" :onDelete="onDelete" :onDuplicate="onDuplicate">
|
|
14
|
+
<button class="action-btn" type="button" title="Duplicate" @click.stop="onDuplicate">
|
|
15
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
|
|
16
|
+
<path d="M16 1H6a2 2 0 0 0-2 2v12h2V3h10V1zm3 4H10a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2zm0 16H10V7h9v14z"/>
|
|
17
|
+
</svg>
|
|
18
|
+
</button>
|
|
14
19
|
<button class="action-btn" type="button" title="Delete" @click.stop="onDelete">
|
|
15
20
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
|
|
16
21
|
<path d="M6.5 1h3a.5.5 0 0 1 .5.5v1H6v-1a.5.5 0 0 1 .5-.5ZM11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3A1.5 1.5 0 0 0 5 1.5v1H2.5a.5.5 0 0 0 0 1h.5v10.5A1.5 1.5 0 0 0 4.5 15h7a1.5 1.5 0 0 0 1.5-1.5V3.5h.5a.5.5 0 0 0 0-1H11Zm1 1v10.5a.5.5 0 0 1-.5.5h-7a.5.5 0 0 1-.5-.5V3.5h8Z"/>
|
|
@@ -77,6 +82,10 @@ export default {
|
|
|
77
82
|
type: Function,
|
|
78
83
|
default: () => {},
|
|
79
84
|
},
|
|
85
|
+
onDuplicate: {
|
|
86
|
+
type: Function,
|
|
87
|
+
default: () => {},
|
|
88
|
+
},
|
|
80
89
|
onDragStart: {
|
|
81
90
|
type: Function,
|
|
82
91
|
default: () => {},
|
|
@@ -124,7 +133,11 @@ export default {
|
|
|
124
133
|
readOnly: {
|
|
125
134
|
type: Boolean,
|
|
126
135
|
default: false,
|
|
127
|
-
}
|
|
136
|
+
},
|
|
137
|
+
ignoreClickOutsideSelectors: {
|
|
138
|
+
type: Array,
|
|
139
|
+
default: () => [],
|
|
140
|
+
},
|
|
128
141
|
},
|
|
129
142
|
data() {
|
|
130
143
|
return {
|
|
@@ -189,9 +202,12 @@ export default {
|
|
|
189
202
|
const x = this.object.x + offsetX + resizeOffsetX
|
|
190
203
|
const y = this.object.y + offsetY + resizeOffsetY
|
|
191
204
|
const width = this.object.width + resizeOffsetW
|
|
205
|
+
const toolbarOffset = 60
|
|
206
|
+
const nextTop = y - toolbarOffset
|
|
207
|
+
const top = nextTop < 0 ? (y + 8) : nextTop
|
|
192
208
|
return {
|
|
193
209
|
left: `${(x + width / 2) * scale}px`,
|
|
194
|
-
top: `${
|
|
210
|
+
top: `${top * scale}px`,
|
|
195
211
|
transform: 'translateX(-50%)',
|
|
196
212
|
}
|
|
197
213
|
},
|
|
@@ -234,6 +250,14 @@ export default {
|
|
|
234
250
|
this.startDrag(event)
|
|
235
251
|
},
|
|
236
252
|
handleClickOutside(event) {
|
|
253
|
+
const selectors = Array.isArray(this.ignoreClickOutsideSelectors)
|
|
254
|
+
? this.ignoreClickOutsideSelectors
|
|
255
|
+
: []
|
|
256
|
+
for (const selector of selectors) {
|
|
257
|
+
if (selector && event?.target?.closest?.(selector)) {
|
|
258
|
+
return
|
|
259
|
+
}
|
|
260
|
+
}
|
|
237
261
|
if (this.$el && !this.$el.contains(event.target)) {
|
|
238
262
|
this.isSelected = false
|
|
239
263
|
}
|
|
@@ -467,7 +491,7 @@ export default {
|
|
|
467
491
|
border-radius: 6px;
|
|
468
492
|
padding: 6px 8px;
|
|
469
493
|
box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.15), 0 2px 6px -2px rgba(0, 0, 0, 0.1);
|
|
470
|
-
z-index:
|
|
494
|
+
z-index: 5;
|
|
471
495
|
white-space: nowrap;
|
|
472
496
|
}
|
|
473
497
|
.action-btn {
|
|
@@ -513,7 +537,7 @@ export default {
|
|
|
513
537
|
display: block;
|
|
514
538
|
appearance: none;
|
|
515
539
|
cursor: pointer;
|
|
516
|
-
z-index:
|
|
540
|
+
z-index: 5;
|
|
517
541
|
}
|
|
518
542
|
.handle-top-left {
|
|
519
543
|
top: -7px;
|