@vue-pdf-viewer/annotation 1.3.0-beta.1 → 1.3.0-beta.3
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/dist/index.js +39 -27
- package/dist/index.umd.cjs +2 -2
- package/dist/utils/pdfSerializer.d.ts +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.vp-text-xl[data-v-9d5f0033]{font-size:1.25rem;line-height:1.75rem}.vpv-toolbar-btn.vpv-toolbar-btn-active[data-v-df5778ee],.vpv-toolbar-btn[data-v-df5778ee]:hover{background-color:var(--vpv-primary-color);color:#fff}.vpv-annotation-editor-layer{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none}.vpv-annotation-editor-layer *{pointer-events:auto}.vpv-annotation-editor-layer .vpv-annotation-editor{z-index:calc(var(--vpv-base-z-index) * 4)}.vpv-annotation-editor-layer.highlight-mode,.vpv-annotation-editor-layer.underline-mode,.vpv-annotation-editor-layer.strikeout-mode{cursor:text}.vpv-annotation-editor-layer.highlight-mode .vpv-annotation-editor,.vpv-annotation-editor-layer.underline-mode .vpv-annotation-editor,.vpv-annotation-editor-layer.strikeout-mode .vpv-annotation-editor{pointer-events:none}.vpv-annotation-editor-layer.highlight-mode .vpv-annotation-editor .vpv-annotation-editor__clip-path,.vpv-annotation-editor-layer.underline-mode .vpv-annotation-editor .vpv-annotation-editor__clip-path,.vpv-annotation-editor-layer.strikeout-mode .vpv-annotation-editor .vpv-annotation-editor__clip-path{
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.vp-text-xl[data-v-9d5f0033]{font-size:1.25rem;line-height:1.75rem}.vpv-toolbar-btn.vpv-toolbar-btn-active[data-v-df5778ee],.vpv-toolbar-btn[data-v-df5778ee]:hover{background-color:var(--vpv-primary-color);color:#fff}.vpv-annotation-editor-layer{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none}.vpv-annotation-editor-layer *{pointer-events:auto}.vpv-annotation-editor-layer .vpv-annotation-editor{z-index:calc(var(--vpv-base-z-index) * 4)}.vpv-annotation-editor-layer.highlight-mode,.vpv-annotation-editor-layer.underline-mode,.vpv-annotation-editor-layer.strikeout-mode{cursor:text}.vpv-annotation-editor-layer.highlight-mode .vpv-annotation-editor,.vpv-annotation-editor-layer.underline-mode .vpv-annotation-editor,.vpv-annotation-editor-layer.strikeout-mode .vpv-annotation-editor{pointer-events:none}.vpv-annotation-editor-layer.highlight-mode .vpv-annotation-editor .vpv-annotation-editor__clip-path,.vpv-annotation-editor-layer.underline-mode .vpv-annotation-editor .vpv-annotation-editor__clip-path,.vpv-annotation-editor-layer.strikeout-mode .vpv-annotation-editor .vpv-annotation-editor__clip-path{position:absolute;inset:0;pointer-events:none;z-index:calc(var(--vpv-base-z-index) * 5)}.vpv-annotation-editor-layer:not(.highlight-mode,.underline-mode,.strikeout-mode) .vpv-annotation-editor.vpv-annotation-editor__highlight{pointer-events:none}.vpv-annotation-editor-layer:not(.highlight-mode,.underline-mode,.strikeout-mode) .vpv-annotation-editor.vpv-annotation-editor__highlight .vpv-annotation-editor__clip-path{pointer-events:none}.vpv-annotation-editor-layer.freetext-mode>:not(.vpv-annotation-editor__free-text){user-select:none;pointer-events:none}.vpv-annotation-editor-layer:not(.freetext-mode) .vpv-annotation-editor__free-text{pointer-events:none}.vpv-annotation-highlight__color-picker-wrapper{padding-left:4px;padding-right:4px;padding-bottom:4px;text-align:left}.vpv-annotation-highlight__color-picker-wrapper>p{margin-bottom:.75rem}.vpv-canvas-layer>.vpv-highlight:is(svg),.vpv-canvas-layer>.vpv-underline:is(svg),.vpv-canvas-layer>.vpv-underline-interaction:is(svg),.vpv-canvas-layer>.vpv-strikeout:is(svg),.vpv-canvas-layer>.vpv-strikeout-interaction:is(svg){position:absolute;mix-blend-mode:multiply;pointer-events:none}.vpv-canvas-layer>.vpv-highlight:is(svg)>use,.vpv-canvas-layer>.vpv-underline:is(svg)>use,.vpv-canvas-layer>.vpv-underline-interaction:is(svg)>use,.vpv-canvas-layer>.vpv-strikeout:is(svg)>use,.vpv-canvas-layer>.vpv-strikeout-interaction:is(svg)>use{fill:inherit}.vpv-canvas-layer>.vpv-highlight:is(svg):not(.free),.vpv-canvas-layer>.vpv-underline:is(svg):not(.free),.vpv-canvas-layer>.vpv-underline-interaction:is(svg):not(.free),.vpv-canvas-layer>.vpv-strikeout:is(svg):not(.free),.vpv-canvas-layer>.vpv-strikeout-interaction:is(svg):not(.free){fill-rule:evenodd}.vpv-canvas-layer>.vpv-highlight:is(svg):not(.free) path,.vpv-canvas-layer>.vpv-highlight:is(svg):not(.free) use,.vpv-canvas-layer>.vpv-underline:is(svg):not(.free) path,.vpv-canvas-layer>.vpv-underline:is(svg):not(.free) use,.vpv-canvas-layer>.vpv-underline-interaction:is(svg):not(.free) path,.vpv-canvas-layer>.vpv-underline-interaction:is(svg):not(.free) use,.vpv-canvas-layer>.vpv-strikeout:is(svg):not(.free) path,.vpv-canvas-layer>.vpv-strikeout:is(svg):not(.free) use,.vpv-canvas-layer>.vpv-strikeout-interaction:is(svg):not(.free) path,.vpv-canvas-layer>.vpv-strikeout-interaction:is(svg):not(.free) use{fill-rule:evenodd}.vpv-canvas-layer>.vpv-highlight-outline:is(svg),.vpv-canvas-layer>.vpv-underline-outline:is(svg),.vpv-canvas-layer>.vpv-strikeout-outline:is(svg){position:absolute;mix-blend-mode:normal;fill-rule:evenodd;fill:transparent;pointer-events:none;stroke:transparent;stroke-width:var(--vpv-annotation-highlight__outline-width)}.vpv-canvas-layer>.vpv-highlight-outline:is(svg) path,.vpv-canvas-layer>.vpv-highlight-outline:is(svg) use,.vpv-canvas-layer>.vpv-underline-outline:is(svg) path,.vpv-canvas-layer>.vpv-underline-outline:is(svg) use,.vpv-canvas-layer>.vpv-strikeout-outline:is(svg) path,.vpv-canvas-layer>.vpv-strikeout-outline:is(svg) use{fill-rule:evenodd}.vpv-canvas-layer>.vpv-highlight-outline:is(svg).selected,.vpv-canvas-layer>.vpv-underline-outline:is(svg).selected,.vpv-canvas-layer>.vpv-strikeout-outline:is(svg).selected{stroke:var(--vpv-annotation-highlight__outline-selected-color)}.vpv-annotation-editor-layer .vpv-annotation-editor__free-text{position:absolute;user-select:none;padding:calc(var(--vpv-annotation-free-text__padding, 2px) * var(--scale-factor));cursor:auto}.vpv-annotation-editor-layer .vpv-annotation-editor__free-text.draggable{cursor:move}.vpv-annotation-editor-layer .vpv-annotation-editor__free-text--selected,.vpv-annotation-editor-layer .vpv-annotation-editor__free-text:hover{outline:1px solid #0082ff}.vpv-annotation-editor-layer .vpv-annotation-editor__free-text [role=textbox]{outline:none!important;text-align:start;font:10px sans-serif;line-height:var(--vpv-annotation-free-text__line-height);width:auto;height:auto;white-space:pre-wrap;word-wrap:break-word}.vpv-annotation-editor-layer .vpv-annotation-editor__free-text--temp{min-width:100px;min-height:calc(20px * var(--scale-factor));border:1px dashed #007bff;background-color:#ffffffe6;color:#000;cursor:text}.vpv-annotation-editor-layer .vpv-annotation-editor__free-text--temp>[role=textbox]{outline:none;font-size:calc(16px * var(--scale-factor));font-family:sans-serif;min-height:calc(16px * var(--scale-factor));white-space:nowrap}.vpv-resizers{position:absolute;inset:0;pointer-events:none}.vpv-resizers .vpv-resizer{position:absolute;width:var(--vpv-annotation-outline-resizer-size);height:var(--vpv-annotation-outline-resizer-size);background:white;border:1px solid var(--vpv-annotation-outline-resizer-border-color);border-radius:50%;pointer-events:auto;cursor:pointer;z-index:calc(var(--vpv-base-z-index) * 9999);transition:opacity .2s ease,visibility .2s ease}.vpv-resizers .vpv-resizer:hover,.vpv-resizers .vpv-resizer:focus{transform:scale(1.5)}.vpv-resizers .vpv-resizer--top-left{top:calc(var(--vpv-annotation-outline-resizer-size) * -1.25);left:calc(var(--vpv-annotation-outline-resizer-size) * -1.25);cursor:nwse-resize}.vpv-resizers .vpv-resizer--top-right{top:calc(var(--vpv-annotation-outline-resizer-size) * -1.25);right:calc(var(--vpv-annotation-outline-resizer-size) * -1.25);cursor:nesw-resize}.vpv-resizers .vpv-resizer--bottom-left{bottom:calc(var(--vpv-annotation-outline-resizer-size) * -1.25);left:calc(var(--vpv-annotation-outline-resizer-size) * -1.25);cursor:nesw-resize}.vpv-resizers .vpv-resizer--bottom-right{bottom:calc(var(--vpv-annotation-outline-resizer-size) * -1.25);right:calc(var(--vpv-annotation-outline-resizer-size) * -1.25);cursor:nwse-resize}.vpv-page[data-main-rotation="90"] .vpv-resizer--top-left,.vpv-page[data-main-rotation="270"] .vpv-resizer--top-left{cursor:nesw-resize}.vpv-page[data-main-rotation="90"] .vpv-resizer--top-right,.vpv-page[data-main-rotation="270"] .vpv-resizer--top-right,.vpv-page[data-main-rotation="90"] .vpv-resizer--bottom-left,.vpv-page[data-main-rotation="270"] .vpv-resizer--bottom-left{cursor:nwse-resize}.vpv-page[data-main-rotation="90"] .vpv-resizer--bottom-right,.vpv-page[data-main-rotation="270"] .vpv-resizer--bottom-right{cursor:nesw-resize}.vpv-resizer--dark{background:#80ebff;border-color:#2b2a33}.vpv-resizer--dark:focus{outline-color:#80ebff}.vpv-annotation-editor__image{position:absolute;cursor:pointer;touch-action:none;user-select:none;will-change:transform}.vpv-annotation-editor__image.hovered,.vpv-annotation-editor__image:hover{outline-width:var(--vpv-annotation-outline-width);outline-style:solid;outline-color:var(--vpv-annotation-outline-hovered-color)}.vpv-annotation-editor__image.selected{outline-width:var(--vpv-annotation-outline-width);outline-style:solid;outline-offset:var(--vpv-annotation-outline-selected-offset);outline-color:var(--vpv-annotation-outline-selected-color);cursor:move}.vpv-annotation-editor__image canvas{position:absolute;width:100%;height:100%;margin:0;top:0;left:0}.vpv-annotation-editor__image.dragging canvas{user-drag:none;-webkit-user-drag:none;pointer-events:none;touch-action:none}.vpv-page:not([data-main-rotation="0"]) .vpv-annotation-editor__image:hover{outline:none}.vpv-annotation-tools-container[data-v-8583d7e5]{padding-top:.5rem;padding-bottom:.5rem;border-top:1px solid #c6ccd2;max-width:min-content;margin:.5rem auto}.vpv-annotation-tools-container[data-v-8583d7e5] .vpv-toolbar-btn{margin-bottom:.25rem}.slide-enter-active[data-v-8583d7e5],.slide-leave-active[data-v-8583d7e5]{transition:all .3s ease-out}.slide-enter-from[data-v-8583d7e5],.slide-leave-to[data-v-8583d7e5]{opacity:0}.slide-enter-from[data-v-8583d7e5],.slide-leave-to[data-v-8583d7e5]{transform:translateY(-20px)}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
2
|
import { defineComponent as Ue, inject as On, computed as de, openBlock as ee, createBlock as ce, resolveDynamicComponent as Se, normalizeProps as St, mergeProps as ve, createSlots as un, withCtx as Q, renderSlot as pe, renderList as Oc, createElementBlock as Sn, useAttrs as Fc, defineAsyncComponent as zc, unref as Be, ref as ui, createTextVNode as Fn, toDisplayString as zn, createVNode as Ae, normalizeClass as Nc, mergeModels as Sr, useModel as kr, createCommentVNode as _e, reactive as Lc, onMounted as Mc, watch as Yn, onUnmounted as jc, Transition as Uc, markRaw as Pt, h as ai } from "vue";
|
|
3
3
|
var $c = Object.defineProperty, Hc = (e, t, n) => t in e ? $c(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, p = (e, t, n) => (Hc(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
4
|
const Lt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", fn = new Uint8Array(256);
|
|
@@ -8751,7 +8751,14 @@ const Df = {
|
|
|
8751
8751
|
class Pf {
|
|
8752
8752
|
static async serializeAnnotationsToPdf(t, n, i) {
|
|
8753
8753
|
const r = await _t.load(t), s = r.getPages();
|
|
8754
|
-
i && i.length > 0
|
|
8754
|
+
if (i && i.length > 0) {
|
|
8755
|
+
const l = typeof i[0] == "string" ? i.map((a) => ({
|
|
8756
|
+
id: a,
|
|
8757
|
+
pageIndex: -1,
|
|
8758
|
+
annotationType: -1
|
|
8759
|
+
})) : i;
|
|
8760
|
+
await this.removeAnnotations(r, s, l);
|
|
8761
|
+
}
|
|
8755
8762
|
const o = n.filter(
|
|
8756
8763
|
(l) => l.annotationType === ct.Underline || l.annotationType === ct.StrikeOut
|
|
8757
8764
|
), c = n.filter(
|
|
@@ -8764,36 +8771,41 @@ class Pf {
|
|
|
8764
8771
|
return await r.save();
|
|
8765
8772
|
}
|
|
8766
8773
|
static async removeAnnotations(t, n, i) {
|
|
8767
|
-
const r = /* @__PURE__ */ new Map();
|
|
8768
|
-
for (const
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8774
|
+
const r = /* @__PURE__ */ new Map(), s = [];
|
|
8775
|
+
for (const o of i)
|
|
8776
|
+
if (o.pageIndex >= 0) {
|
|
8777
|
+
const c = r.get(o.pageIndex) || [];
|
|
8778
|
+
c.push(o), r.set(o.pageIndex, c);
|
|
8779
|
+
} else
|
|
8780
|
+
s.push(o);
|
|
8781
|
+
for (let o = 0; o < n.length; o++) {
|
|
8782
|
+
const c = n[o], l = [
|
|
8783
|
+
...r.get(o) || [],
|
|
8784
|
+
...s
|
|
8785
|
+
];
|
|
8786
|
+
if (l.length === 0)
|
|
8775
8787
|
continue;
|
|
8776
|
-
const
|
|
8777
|
-
if (!
|
|
8788
|
+
const a = c.node.Annots();
|
|
8789
|
+
if (!a || !(a instanceof q))
|
|
8778
8790
|
continue;
|
|
8779
|
-
const
|
|
8780
|
-
for (let
|
|
8781
|
-
const
|
|
8782
|
-
let
|
|
8783
|
-
if (
|
|
8784
|
-
const
|
|
8785
|
-
|
|
8791
|
+
const h = [];
|
|
8792
|
+
for (let u = 0; u < a.size(); u++) {
|
|
8793
|
+
const f = a.get(u);
|
|
8794
|
+
let d;
|
|
8795
|
+
if (f instanceof re) {
|
|
8796
|
+
const y = t.context.lookup(f);
|
|
8797
|
+
y instanceof G && (d = y);
|
|
8786
8798
|
} else
|
|
8787
|
-
|
|
8788
|
-
if (!
|
|
8799
|
+
f instanceof G && (d = f);
|
|
8800
|
+
if (!d)
|
|
8789
8801
|
continue;
|
|
8790
8802
|
this.matchesDeletedAnnotation(
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
) &&
|
|
8803
|
+
d,
|
|
8804
|
+
l
|
|
8805
|
+
) && h.push(u);
|
|
8794
8806
|
}
|
|
8795
|
-
for (let
|
|
8796
|
-
|
|
8807
|
+
for (let u = h.length - 1; u >= 0; u--)
|
|
8808
|
+
a.remove(h[u]);
|
|
8797
8809
|
}
|
|
8798
8810
|
}
|
|
8799
8811
|
static matchesDeletedAnnotation(t, n) {
|
|
@@ -8816,7 +8828,7 @@ class Pf {
|
|
|
8816
8828
|
if (a.length !== 4)
|
|
8817
8829
|
return !1;
|
|
8818
8830
|
for (const h of n) {
|
|
8819
|
-
if (h.annotationType !== c || !h.rect || h.rect.length !== 4)
|
|
8831
|
+
if (h.annotationType !== -1 && h.annotationType !== c || !h.rect || h.rect.length !== 4)
|
|
8820
8832
|
continue;
|
|
8821
8833
|
const u = 1;
|
|
8822
8834
|
if (Math.abs(a[0] - h.rect[0]) < u && Math.abs(a[1] - h.rect[1]) < u && Math.abs(a[2] - h.rect[2]) < u && Math.abs(a[3] - h.rect[3]) < u)
|