@libresign/pdf-elements 0.1.1 → 0.2.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 CHANGED
@@ -13,18 +13,19 @@ A Vue 2 component for rendering PDFs with draggable and resizable element overla
13
13
 
14
14
  ### Props
15
15
 
16
- | Prop | Type | Default |
17
- |------|------|---------|
18
- | `width` | String | `'100%'` |
19
- | `height` | String | `'100%'` |
20
- | `initFiles` | Array | `[]` |
21
- | `initFileNames` | Array | `[]` |
22
- | `initialScale` | Number | `1` |
23
- | `showPageFooter` | Boolean | `true` |
24
- | `hideSelectionUI` | Boolean | `false` |
25
- | `showSelectionHandles` | Boolean | `true` |
26
- | `showElementActions` | Boolean | `true` |
27
- | `pageCountFormat` | String | `'{currentPage} of {totalPages}'` |
16
+ | Prop | Type | Default | Description |
17
+ |------|------|---------|-------------|
18
+ | `width` | String | `'100%'` | Container width |
19
+ | `height` | String | `'100%'` | Container height |
20
+ | `initFiles` | Array | `[]` | PDF files to load |
21
+ | `initFileNames` | Array | `[]` | Names for the PDF files |
22
+ | `initialScale` | Number | `1` | Initial zoom scale |
23
+ | `showPageFooter` | Boolean | `true` | Show page footer with document name and page number |
24
+ | `hideSelectionUI` | Boolean | `false` | Hide selection handles and actions UI |
25
+ | `showSelectionHandles` | Boolean | `true` | Show resize/move handles on selected elements |
26
+ | `showElementActions` | Boolean | `true` | Show action buttons on selected elements |
27
+ | `pageCountFormat` | String | `'{currentPage} of {totalPages}'` | Format string for page counter |
28
+ | `autoFitZoom` | Boolean | `false` | Automatically adjust zoom to fit viewport on window resize |
28
29
 
29
30
  ### Events
30
31
 
@@ -35,3 +36,4 @@ A Vue 2 component for rendering PDFs with draggable and resizable element overla
35
36
  - `element-{type}` - Custom element rendering (e.g., `element-signature`)
36
37
  - `custom` - Fallback for elements without specific type
37
38
  - `actions` - Custom action buttons
39
+
@@ -196,22 +196,6 @@ module.exports = !fails(function () {
196
196
  });
197
197
 
198
198
 
199
- /***/ },
200
-
201
- /***/ 655
202
- (module, __unused_webpack_exports, __webpack_require__) {
203
-
204
-
205
- var classof = __webpack_require__(6955);
206
-
207
- var $String = String;
208
-
209
- module.exports = function (argument) {
210
- if (classof(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string');
211
- return $String(argument);
212
- };
213
-
214
-
215
199
  /***/ },
216
200
 
217
201
  /***/ 679
@@ -286,13 +270,6 @@ module.exports = USE_SYMBOL_AS_UID ? function (it) {
286
270
  };
287
271
 
288
272
 
289
- /***/ },
290
-
291
- /***/ 824
292
- (module, __unused_webpack_exports, __webpack_require__) {
293
-
294
- module.exports = __webpack_require__.p + "pdf.worker.min.mjs";
295
-
296
273
  /***/ },
297
274
 
298
275
  /***/ 851
@@ -951,20 +928,6 @@ var POLYFILL = isForced.POLYFILL = 'P';
951
928
  module.exports = isForced;
952
929
 
953
930
 
954
- /***/ },
955
-
956
- /***/ 2812
957
- (module) {
958
-
959
-
960
- var $TypeError = TypeError;
961
-
962
- module.exports = function (passed, required) {
963
- if (passed < required) throw new $TypeError('Not enough arguments');
964
- return passed;
965
- };
966
-
967
-
968
931
  /***/ },
969
932
 
970
933
  /***/ 2839
@@ -1293,62 +1256,6 @@ module.exports =
1293
1256
  (function () { return this; })() || Function('return this')();
1294
1257
 
1295
1258
 
1296
- /***/ },
1297
-
1298
- /***/ 4603
1299
- (__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
1300
-
1301
-
1302
- var defineBuiltIn = __webpack_require__(6840);
1303
- var uncurryThis = __webpack_require__(9504);
1304
- var toString = __webpack_require__(655);
1305
- var validateArgumentsLength = __webpack_require__(2812);
1306
-
1307
- var $URLSearchParams = URLSearchParams;
1308
- var URLSearchParamsPrototype = $URLSearchParams.prototype;
1309
- var append = uncurryThis(URLSearchParamsPrototype.append);
1310
- var $delete = uncurryThis(URLSearchParamsPrototype['delete']);
1311
- var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
1312
- var push = uncurryThis([].push);
1313
- var params = new $URLSearchParams('a=1&a=2&b=3');
1314
-
1315
- params['delete']('a', 1);
1316
- // `undefined` case is a Chromium 117 bug
1317
- // https://bugs.chromium.org/p/v8/issues/detail?id=14222
1318
- params['delete']('b', undefined);
1319
-
1320
- if (params + '' !== 'a=2') {
1321
- defineBuiltIn(URLSearchParamsPrototype, 'delete', function (name /* , value */) {
1322
- var length = arguments.length;
1323
- var $value = length < 2 ? undefined : arguments[1];
1324
- if (length && $value === undefined) return $delete(this, name);
1325
- var entries = [];
1326
- forEach(this, function (v, k) { // also validates `this`
1327
- push(entries, { key: k, value: v });
1328
- });
1329
- validateArgumentsLength(length, 1);
1330
- var key = toString(name);
1331
- var value = toString($value);
1332
- var index = 0;
1333
- var dindex = 0;
1334
- var found = false;
1335
- var entriesLength = entries.length;
1336
- var entry;
1337
- while (index < entriesLength) {
1338
- entry = entries[index++];
1339
- if (found || entry.key === key) {
1340
- found = true;
1341
- $delete(this, entry.key);
1342
- } else dindex++;
1343
- }
1344
- while (dindex < entriesLength) {
1345
- entry = entries[dindex++];
1346
- if (!(entry.key === key && entry.value === value)) append(this, entry.key, entry.value);
1347
- }
1348
- }, { enumerable: true, unsafe: true });
1349
- }
1350
-
1351
-
1352
1259
  /***/ },
1353
1260
 
1354
1261
  /***/ 4659
@@ -1973,41 +1880,6 @@ module.exports = function (fn) {
1973
1880
  };
1974
1881
 
1975
1882
 
1976
- /***/ },
1977
-
1978
- /***/ 7566
1979
- (__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
1980
-
1981
-
1982
- var defineBuiltIn = __webpack_require__(6840);
1983
- var uncurryThis = __webpack_require__(9504);
1984
- var toString = __webpack_require__(655);
1985
- var validateArgumentsLength = __webpack_require__(2812);
1986
-
1987
- var $URLSearchParams = URLSearchParams;
1988
- var URLSearchParamsPrototype = $URLSearchParams.prototype;
1989
- var getAll = uncurryThis(URLSearchParamsPrototype.getAll);
1990
- var $has = uncurryThis(URLSearchParamsPrototype.has);
1991
- var params = new $URLSearchParams('a=1');
1992
-
1993
- // `undefined` case is a Chromium 117 bug
1994
- // https://bugs.chromium.org/p/v8/issues/detail?id=14222
1995
- if (params.has('a', 2) || !params.has('a', undefined)) {
1996
- defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name /* , value */) {
1997
- var length = arguments.length;
1998
- var $value = length < 2 ? undefined : arguments[1];
1999
- if (length && $value === undefined) return $has(this, name);
2000
- var values = getAll(this, name); // also validates `this`
2001
- validateArgumentsLength(length, 1);
2002
- var value = toString($value);
2003
- var index = 0;
2004
- while (index < values.length) {
2005
- if (values[index++] === value) return true;
2006
- } return false;
2007
- }, { enumerable: true, unsafe: true });
2008
- }
2009
-
2010
-
2011
1883
  /***/ },
2012
1884
 
2013
1885
  /***/ 7588
@@ -2372,34 +2244,6 @@ module.exports = DESCRIPTORS && fails(function () {
2372
2244
  });
2373
2245
 
2374
2246
 
2375
- /***/ },
2376
-
2377
- /***/ 8721
2378
- (__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
2379
-
2380
-
2381
- var DESCRIPTORS = __webpack_require__(3724);
2382
- var uncurryThis = __webpack_require__(9504);
2383
- var defineBuiltInAccessor = __webpack_require__(2106);
2384
-
2385
- var URLSearchParamsPrototype = URLSearchParams.prototype;
2386
- var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
2387
-
2388
- // `URLSearchParams.prototype.size` getter
2389
- // https://github.com/whatwg/url/pull/734
2390
- if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
2391
- defineBuiltInAccessor(URLSearchParamsPrototype, 'size', {
2392
- get: function size() {
2393
- var count = 0;
2394
- forEach(this, function () { count++; });
2395
- return count;
2396
- },
2397
- configurable: true,
2398
- enumerable: true
2399
- });
2400
- }
2401
-
2402
-
2403
2247
  /***/ },
2404
2248
 
2405
2249
  /***/ 8727
@@ -2791,9 +2635,6 @@ module.exports = {
2791
2635
  /******/ return module.exports;
2792
2636
  /******/ }
2793
2637
  /******/
2794
- /******/ // expose the modules object (__webpack_modules__)
2795
- /******/ __webpack_require__.m = __webpack_modules__;
2796
- /******/
2797
2638
  /************************************************************************/
2798
2639
  /******/ /* webpack/runtime/define property getters */
2799
2640
  /******/ (() => {
@@ -2817,32 +2658,6 @@ module.exports = {
2817
2658
  /******/ __webpack_require__.p = "";
2818
2659
  /******/ })();
2819
2660
  /******/
2820
- /******/ /* webpack/runtime/jsonp chunk loading */
2821
- /******/ (() => {
2822
- /******/ __webpack_require__.b = (typeof document !== 'undefined' && document.baseURI) || self.location.href;
2823
- /******/
2824
- /******/ // object to store loaded and loading chunks
2825
- /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
2826
- /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
2827
- /******/ var installedChunks = {
2828
- /******/ 380: 0
2829
- /******/ };
2830
- /******/
2831
- /******/ // no chunk on demand loading
2832
- /******/
2833
- /******/ // no prefetching
2834
- /******/
2835
- /******/ // no preloaded
2836
- /******/
2837
- /******/ // no HMR
2838
- /******/
2839
- /******/ // no HMR manifest
2840
- /******/
2841
- /******/ // no on chunks loaded
2842
- /******/
2843
- /******/ // no jsonp function
2844
- /******/ })();
2845
- /******/
2846
2661
  /************************************************************************/
2847
2662
  var __webpack_exports__ = {};
2848
2663
 
@@ -2871,7 +2686,7 @@ if (typeof window !== 'undefined') {
2871
2686
  // Indicate to webpack that this file can be concatenated
2872
2687
  /* harmony default export */ const setPublicPath = (null);
2873
2688
 
2874
- ;// ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/PDFElements.vue?vue&type=template&id=5a4a7f3b&scoped=true
2689
+ ;// ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/PDFElements.vue?vue&type=template&id=7a179460&scoped=true
2875
2690
  var render = function render() {
2876
2691
  var _vm = this,
2877
2692
  _c = _vm._self._c;
@@ -3823,12 +3638,6 @@ var DraggableElement_component = normalizeComponent(
3823
3638
  )
3824
3639
 
3825
3640
  /* harmony default export */ const DraggableElement = (DraggableElement_component.exports);
3826
- // EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.delete.js
3827
- var web_url_search_params_delete = __webpack_require__(4603);
3828
- // EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.has.js
3829
- var web_url_search_params_has = __webpack_require__(7566);
3830
- // EXTERNAL MODULE: ./node_modules/core-js/modules/web.url-search-params.size.js
3831
- var web_url_search_params_size = __webpack_require__(8721);
3832
3641
  ;// ./node_modules/pdfjs-dist/build/pdf.mjs
3833
3642
  /**
3834
3643
  * @licstart The following is the entire license notice for the
@@ -30221,16 +30030,15 @@ globalThis.pdfjsLib = {
30221
30030
 
30222
30031
 
30223
30032
  //# sourceMappingURL=pdf.mjs.map
30033
+ ;// ./node_modules/pdfjs-dist/build/pdf.worker.min.mjs
30034
+ const pdf_worker_min_namespaceObject = __webpack_require__.p + "pdf.worker.min.mjs";
30224
30035
  ;// ./src/utils/asyncReader.js
30225
-
30226
-
30227
-
30228
30036
  // SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
30229
30037
  // SPDX-License-Identifier: AGPL-3.0-or-later
30230
30038
 
30231
30039
 
30232
- const workerUrl = new URL(/* asset import */ __webpack_require__(824), __webpack_require__.b).href;
30233
- GlobalWorkerOptions.workerSrc = workerUrl;
30040
+
30041
+ GlobalWorkerOptions.workerSrc = pdf_worker_min_namespaceObject;
30234
30042
  function readAsArrayBuffer(file) {
30235
30043
  return new Promise((resolve, reject) => {
30236
30044
  const reader = new FileReader();
@@ -30299,6 +30107,10 @@ function readAsPDF(file) {
30299
30107
  pageCountFormat: {
30300
30108
  type: String,
30301
30109
  default: '{currentPage} of {totalPages}'
30110
+ },
30111
+ autoFitZoom: {
30112
+ type: Boolean,
30113
+ default: false
30302
30114
  }
30303
30115
  },
30304
30116
  data() {
@@ -30371,6 +30183,9 @@ function readAsPDF(file) {
30371
30183
  this.$el?.addEventListener('wheel', this.boundHandleWheel, {
30372
30184
  passive: false
30373
30185
  });
30186
+ if (this.autoFitZoom) {
30187
+ window.addEventListener('resize', this.adjustZoomToFit);
30188
+ }
30374
30189
  },
30375
30190
  beforeUnmount() {
30376
30191
  if (this.zoomRafId) {
@@ -30388,6 +30203,9 @@ function readAsPDF(file) {
30388
30203
  window.removeEventListener('scroll', this.onViewportScroll);
30389
30204
  window.removeEventListener('resize', this.onViewportScroll);
30390
30205
  this.$el?.removeEventListener('scroll', this.onViewportScroll);
30206
+ if (this.autoFitZoom) {
30207
+ window.removeEventListener('resize', this.adjustZoomToFit);
30208
+ }
30391
30209
  if (this.viewportRafId) {
30392
30210
  window.cancelAnimationFrame(this.viewportRafId);
30393
30211
  this.viewportRafId = 0;
@@ -30866,15 +30684,32 @@ function readAsPDF(file) {
30866
30684
  const doc = this.pdfDocuments[docIndex];
30867
30685
  const pagesScale = doc.pagesScale[pageIndex] || 1;
30868
30686
  return pageRef.getCanvasMeasurement().canvasHeight / pagesScale;
30687
+ },
30688
+ calculateOptimalScale(maxPageWidth) {
30689
+ const containerWidth = this.$el?.clientWidth || 0;
30690
+ if (!containerWidth || !maxPageWidth) return 1;
30691
+ const availableWidth = containerWidth - 40;
30692
+ return Math.max(0.1, Math.min(2, availableWidth / maxPageWidth));
30693
+ },
30694
+ adjustZoomToFit() {
30695
+ if (!this.autoFitZoom || !this.pdfDocuments.length) return;
30696
+ const canvases = this.$el?.querySelectorAll('canvas');
30697
+ if (!canvases?.length) return;
30698
+ const maxCanvasWidth = Math.max(...Array.from(canvases).map(canvas => canvas.width / (this.scale || 1)));
30699
+ const optimalScale = this.calculateOptimalScale(maxCanvasWidth);
30700
+ if (Math.abs(optimalScale - this.scale) > 0.01) {
30701
+ this.scale = optimalScale;
30702
+ this.visualScale = optimalScale;
30703
+ }
30869
30704
  }
30870
30705
  }
30871
30706
  });
30872
30707
  ;// ./src/components/PDFElements.vue?vue&type=script&lang=js
30873
30708
  /* harmony default export */ const components_PDFElementsvue_type_script_lang_js = (PDFElementsvue_type_script_lang_js);
30874
- ;// ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/PDFElements.vue?vue&type=style&index=0&id=5a4a7f3b&prod&scoped=true&lang=css
30709
+ ;// ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-12.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-12.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-12.use[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/PDFElements.vue?vue&type=style&index=0&id=7a179460&prod&scoped=true&lang=css
30875
30710
  // extracted by mini-css-extract-plugin
30876
30711
 
30877
- ;// ./src/components/PDFElements.vue?vue&type=style&index=0&id=5a4a7f3b&prod&scoped=true&lang=css
30712
+ ;// ./src/components/PDFElements.vue?vue&type=style&index=0&id=7a179460&prod&scoped=true&lang=css
30878
30713
 
30879
30714
  ;// ./src/components/PDFElements.vue
30880
30715
 
@@ -30891,7 +30726,7 @@ var PDFElements_component = normalizeComponent(
30891
30726
  staticRenderFns,
30892
30727
  false,
30893
30728
  null,
30894
- "5a4a7f3b",
30729
+ "7a179460",
30895
30730
  null
30896
30731
 
30897
30732
  )