@embedpdf-editor/vue3-chapter-viewer 0.3.5 → 1.0.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/LICENSE.pdfium +196 -0
- package/NOTICE +5 -0
- package/NOTICE.pdfium +13 -0
- package/THIRD-PARTY-NOTICES.md +102 -0
- package/dist/LICENSE.pdfium +196 -0
- package/dist/NOTICE.pdfium +13 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +166 -145
- package/dist/index.js.map +1 -1
- package/package.json +9 -6
package/dist/index.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ export declare function buildParagraphBookmarkAnchor(chapterId: string, localPag
|
|
|
71
71
|
}): ParagraphBookmark['anchor'];
|
|
72
72
|
|
|
73
73
|
/** 选区浮窗 card 内置操作 */
|
|
74
|
-
declare type BuiltinSelectionToolbarAction = 'highlight' | 'underline' | 'squiggly' | 'strikeout' | 'note';
|
|
74
|
+
declare type BuiltinSelectionToolbarAction = 'copy' | 'highlight' | 'underline' | 'squiggly' | 'strikeout' | 'note';
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* 回调型:把决策交给业务侧异步函数(最常用)。
|
|
@@ -839,6 +839,8 @@ declare interface SelectionToolbarConfig {
|
|
|
839
839
|
enabled?: boolean;
|
|
840
840
|
/** 隐藏部分内置按钮 */
|
|
841
841
|
hiddenBuiltinActions?: BuiltinSelectionToolbarAction[];
|
|
842
|
+
/** 自定义复制按钮图标;不提供则使用默认图标 */
|
|
843
|
+
renderCopyIcon?: () => unknown;
|
|
842
844
|
/** 扩展操作(由宿主在 buildSelectionMenu 或 onExtraAction 中处理) */
|
|
843
845
|
extraActions?: SelectionToolbarExtraAction[];
|
|
844
846
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, computed,
|
|
1
|
+
import { defineComponent, computed, openBlock, createElementBlock, normalizeStyle, unref, normalizeClass, createVNode, withCtx, renderSlot, createCommentVNode, h as h$1, ref, watch, onBeforeUnmount, onMounted, createElementVNode, Fragment, renderList, createBlock, resolveDynamicComponent, withModifiers, isRef, toDisplayString, normalizeProps, guardReactiveProps, createSlots } from "vue";
|
|
2
2
|
import { useRegistry, useCapability, EmbedPDF } from "@embedpdf/core/vue";
|
|
3
3
|
import { EmbedPDF as EmbedPDF2, useCapability as useCapability2, useRegistry as useRegistry2 } from "@embedpdf/core/vue";
|
|
4
4
|
import { LockModeType, AnnotationPluginPackage, AnnotationPlugin, ANNOTATION_PLUGIN_ID } from "@embedpdf/plugin-annotation";
|
|
@@ -29,7 +29,7 @@ function we$1() {
|
|
|
29
29
|
var _a2;
|
|
30
30
|
"undefined" != typeof window && ((_a2 = window.getSelection()) == null ? void 0 : _a2.removeAllRanges());
|
|
31
31
|
}
|
|
32
|
-
const ye = "#f1f5f9", Ce = { highlight: { offsetY: 0 }, underline: { offsetY: 2.5 }, squiggly: { offsetY: 4 }, strikeout: { offsetY: 0 } }, Ie = { highlight: PdfAnnotationSubtype.HIGHLIGHT, underline: PdfAnnotationSubtype.UNDERLINE, squiggly: PdfAnnotationSubtype.SQUIGGLY, strikeout: PdfAnnotationSubtype.STRIKEOUT };
|
|
32
|
+
const ye$1 = "#f1f5f9", Ce = { highlight: { offsetY: 0 }, underline: { offsetY: 2.5 }, squiggly: { offsetY: 4 }, strikeout: { offsetY: 0 } }, Ie = { highlight: PdfAnnotationSubtype.HIGHLIGHT, underline: PdfAnnotationSubtype.UNDERLINE, squiggly: PdfAnnotationSubtype.SQUIGGLY, strikeout: PdfAnnotationSubtype.STRIKEOUT };
|
|
33
33
|
function Me(e14, t2) {
|
|
34
34
|
return 0 === t2 ? e14 : e14.map((e15) => ({ origin: { x: e15.origin.x, y: e15.origin.y + t2 }, size: { ...e15.size } }));
|
|
35
35
|
}
|
|
@@ -62,7 +62,7 @@ function Le(e14, t2) {
|
|
|
62
62
|
function $e(e14) {
|
|
63
63
|
var t2;
|
|
64
64
|
const a3 = Le(null == e14 ? void 0 : e14.markup, { enabled: true }), s9 = Le(null == e14 ? void 0 : e14.bookmarks, { enabled: true }), i2 = Le(null == e14 ? void 0 : e14.notes, { enabled: true }), o = Le(null == e14 ? void 0 : e14.zoom, { enabled: true, min: 0.5, max: 3, initial: 1 }), r2 = Le(void 0 === (null == e14 ? void 0 : e14.selectionToolbar) ? false !== a3.enabled || false !== i2.enabled : e14.selectionToolbar, { enabled: true });
|
|
65
|
-
return { markup: a3, bookmarks: s9, notes: i2, zoom: o, scrollViewport: { background: (null == (t2 = null == e14 ? void 0 : e14.scrollViewport) ? void 0 : t2.background) ?? ye }, selectionToolbar: r2 };
|
|
65
|
+
return { markup: a3, bookmarks: s9, notes: i2, zoom: o, scrollViewport: { background: (null == (t2 = null == e14 ? void 0 : e14.scrollViewport) ? void 0 : t2.background) ?? ye$1 }, selectionToolbar: r2 };
|
|
66
66
|
}
|
|
67
67
|
class ze {
|
|
68
68
|
constructor(e14) {
|
|
@@ -2574,12 +2574,16 @@ function ma(e14) {
|
|
|
2574
2574
|
return e14 instanceof HTMLElement ? e14.clientWidth : 0;
|
|
2575
2575
|
}
|
|
2576
2576
|
function va(o, r2, n2) {
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2577
|
+
const l = isRef(o) ? o : computed(() => o), { registry: h2 } = useRegistry(), { provides: d2 } = useCapability(DocumentManagerPlugin.id), { provides: c } = useCapability(We.id), u = ref(v()), p2 = ref(u.value), g2 = ref(0), f = () => {
|
|
2578
|
+
var _a2;
|
|
2579
|
+
return (_a2 = r2.value) == null ? void 0 : _a2.pageWidth;
|
|
2580
|
+
}, m = () => (function(e14) {
|
|
2581
|
+
return null != e14 && e14 > 0;
|
|
2582
|
+
})(f()), v = () => {
|
|
2583
|
+
var _a2;
|
|
2584
|
+
return ((_a2 = r2.value) == null ? void 0 : _a2.initial) ?? 1;
|
|
2585
|
+
}, b = computed(() => {
|
|
2586
|
+
var _a2;
|
|
2583
2587
|
return (function(e14, t2, a3, s9, i2) {
|
|
2584
2588
|
if (!e14 || a3 <= 0) return i2;
|
|
2585
2589
|
let o2 = i2;
|
|
@@ -2588,14 +2592,14 @@ function va(o, r2, n2) {
|
|
|
2588
2592
|
t3 && (o2 = Math.min(o2, fa(t3, a3, s9, i2)));
|
|
2589
2593
|
}
|
|
2590
2594
|
return o2;
|
|
2591
|
-
})(d2.value, l.value, g2.value, f(), ((
|
|
2592
|
-
}),
|
|
2593
|
-
var
|
|
2594
|
-
return Math.min(((
|
|
2595
|
+
})(d2.value, l.value, g2.value, f(), ((_a2 = r2.value) == null ? void 0 : _a2.max) ?? 3);
|
|
2596
|
+
}), P = computed(() => {
|
|
2597
|
+
var _a2;
|
|
2598
|
+
return Math.min(((_a2 = r2.value) == null ? void 0 : _a2.min) ?? 0.5, b.value);
|
|
2595
2599
|
});
|
|
2596
|
-
let
|
|
2597
|
-
function
|
|
2598
|
-
const t2 =
|
|
2600
|
+
let w;
|
|
2601
|
+
function y(e14) {
|
|
2602
|
+
const t2 = b.value, a3 = P.value, s9 = ua(e14, a3, t2);
|
|
2599
2603
|
p2.value = s9, u.value = s9, (function(e15, t3, a4, s10 = 0.5, i2 = 3) {
|
|
2600
2604
|
const o2 = e15 == null ? void 0 : e15.getStore();
|
|
2601
2605
|
if (!o2) return;
|
|
@@ -2604,18 +2608,18 @@ function va(o, r2, n2) {
|
|
|
2604
2608
|
for (const n3 of t3.chapters) o2.getState().core.documents[n3.chapterId] && o2.dispatchToCore(setScale(r3, n3.chapterId));
|
|
2605
2609
|
})(h2.value, l.value, s9, a3, t2);
|
|
2606
2610
|
}
|
|
2607
|
-
function
|
|
2611
|
+
function C(e14) {
|
|
2608
2612
|
if (!d2.value) return;
|
|
2609
2613
|
const t2 = d2.value.getDocument(e14);
|
|
2610
2614
|
if (!t2) return;
|
|
2611
2615
|
const a3 = ga(g2.value, f());
|
|
2612
|
-
a3 <= 0 ||
|
|
2616
|
+
a3 <= 0 || y(pa(t2, a3));
|
|
2613
2617
|
}
|
|
2614
|
-
function
|
|
2615
|
-
|
|
2618
|
+
function I(e14) {
|
|
2619
|
+
m() ? C(e14) : y(v());
|
|
2616
2620
|
}
|
|
2617
2621
|
return watch(() => n2 == null ? void 0 : n2.value, (e14) => {
|
|
2618
|
-
|
|
2622
|
+
w == null ? void 0 : w(), w = e14 ? (function(e15, t2) {
|
|
2619
2623
|
if (!e15 || "undefined" == typeof ResizeObserver) return () => {
|
|
2620
2624
|
};
|
|
2621
2625
|
let a3 = null;
|
|
@@ -2635,39 +2639,29 @@ function va(o, r2, n2) {
|
|
|
2635
2639
|
})(e14, (e15) => {
|
|
2636
2640
|
g2.value = e15;
|
|
2637
2641
|
}) : void 0;
|
|
2638
|
-
}, { immediate: true }), onBeforeUnmount(() =>
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
return (_a3 = r2.value) == null ? void 0 : _a3.pageWidth;
|
|
2644
|
-
}, g2], () => {
|
|
2645
|
-
var _a3;
|
|
2646
|
-
h2.value && (null != f() || g2.value > 0 || P(((_a3 = r2.value) == null ? void 0 : _a3.initial) ?? 1));
|
|
2647
|
-
}, { immediate: true }), watch(m, (e14) => {
|
|
2648
|
-
p2.value > e14 && P(e14);
|
|
2649
|
-
}), watch([c, l, () => {
|
|
2650
|
-
var _a3;
|
|
2651
|
-
return (_a3 = r2.value) == null ? void 0 : _a3.pageWidth;
|
|
2652
|
-
}, g2], () => {
|
|
2642
|
+
}, { immediate: true }), onBeforeUnmount(() => w == null ? void 0 : w()), watch([h2, () => v(), () => m()], () => {
|
|
2643
|
+
h2.value && (m() || y(v()));
|
|
2644
|
+
}, { immediate: true }), watch(b, (e14) => {
|
|
2645
|
+
p2.value > e14 && y(e14);
|
|
2646
|
+
}), watch([c, l, () => m(), () => v()], () => {
|
|
2653
2647
|
const e14 = c.value;
|
|
2654
2648
|
if (e14) {
|
|
2655
|
-
for (const t2 of l.value.chapters) "loaded" === e14.getChapterStatus(t2.chapterId) &&
|
|
2649
|
+
for (const t2 of l.value.chapters) "loaded" === e14.getChapterStatus(t2.chapterId) && I(t2.chapterId);
|
|
2656
2650
|
return e14.onChapterStatusChange((e15) => {
|
|
2657
|
-
"loaded" === e15.status &&
|
|
2651
|
+
"loaded" === e15.status && I(e15.chapterId);
|
|
2658
2652
|
});
|
|
2659
2653
|
}
|
|
2660
|
-
}, { immediate: true }), watch(g2, (
|
|
2661
|
-
if (!(
|
|
2662
|
-
for (const
|
|
2663
|
-
|
|
2654
|
+
}, { immediate: true }), watch([g2, () => m(), c, l], () => {
|
|
2655
|
+
if (m() && !(g2.value <= 0) && c.value) {
|
|
2656
|
+
for (const e14 of l.value.chapters) if ("loaded" === c.value.getChapterStatus(e14.chapterId)) {
|
|
2657
|
+
C(e14.chapterId);
|
|
2664
2658
|
break;
|
|
2665
2659
|
}
|
|
2666
2660
|
}
|
|
2667
|
-
}), { scale: u, setScale:
|
|
2668
|
-
var
|
|
2669
|
-
return false !== ((
|
|
2670
|
-
}, minZoom:
|
|
2661
|
+
}), { scale: u, setScale: y, zoomEnabled: () => {
|
|
2662
|
+
var _a2;
|
|
2663
|
+
return false !== ((_a2 = r2.value) == null ? void 0 : _a2.enabled);
|
|
2664
|
+
}, minZoom: P, maxZoom: b };
|
|
2671
2665
|
}
|
|
2672
2666
|
function ba(e14, t2, a3) {
|
|
2673
2667
|
return Math.min(a3, Math.max(t2, e14));
|
|
@@ -4254,18 +4248,82 @@ const ms = /* @__PURE__ */ defineComponent({ __name: "HoverBookmarkLayer", props
|
|
|
4254
4248
|
var _a2;
|
|
4255
4249
|
return unref(u) && e14.pdfPageWidth && e14.pdfPageHeight ? (openBlock(), createElementBlock("div", { key: 0, ref_key: "rootRef", ref: p2, style: { position: "absolute", inset: "0", zIndex: 14, pointerEvents: "none" } }, [T2.value && y.value && !L2.value ? (openBlock(), createElementBlock("div", { key: 0, style: normalizeStyle({ position: "absolute", left: `${T2.value.zoneLeft}px`, top: `${T2.value.zoneTop}px`, width: `${T2.value.size + 20}px`, height: `${(((_a2 = y.value[y.value.length - 1]) == null ? void 0 : _a2.size.height) ?? 0) * (e14.cssPageHeight / e14.pdfPageHeight) + T2.value.size + 12}px`, pointerEvents: "auto" }), onMouseenter: a3[0] || (a3[0] = (e15) => P.value = y.value), onMouseleave: a3[1] || (a3[1] = (e15) => P.value = null) }, [createElementVNode("button", { type: "button", title: "添加书签", style: normalizeStyle({ position: "absolute", left: T2.value.iconLeft - T2.value.zoneLeft + "px", top: T2.value.iconTop - T2.value.zoneTop + "px", width: `${T2.value.size}px`, height: `${T2.value.size}px`, cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", background: "#3b82f6", color: "#fff", border: "none", borderRadius: "4px", boxShadow: "0 2px 8px rgba(37, 99, 235, 0.45)", fontSize: "12px", padding: 0 }), onClick: withModifiers($2, ["stop"]) }, " 🔖 ", 4)], 36)) : createCommentVNode("", true)], 512)) : createCommentVNode("", true);
|
|
4256
4250
|
};
|
|
4257
|
-
} }), vs = { key: 0, width: "24", height: "24", viewBox: "0 0 28 28", fill: "none", "aria-hidden": "" },
|
|
4258
|
-
const i2 = e14, o = s9, r2 = [{ id: "highlight", label: "高亮背景" }, { id: "underline", label: "下划线" }, { id: "squiggly", label: "波浪线" }, { id: "strikeout", label: "删除线" }
|
|
4259
|
-
function
|
|
4260
|
-
return { display: "flex", alignItems: "center", justifyContent: "center", width: "32px", height: "32px", padding: 0, margin: 0, border: "none", borderRadius: "8px", background:
|
|
4261
|
-
}
|
|
4262
|
-
const
|
|
4263
|
-
return (
|
|
4264
|
-
} }),
|
|
4265
|
-
|
|
4251
|
+
} }), vs = { key: 0, width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "" }, bs = { key: 1, width: "24", height: "24", viewBox: "0 0 28 28", fill: "none", "aria-hidden": "" }, Ps = { key: 0, x: "5", y: "4", width: "18", height: "20", rx: "3", fill: "#fde047" }, ws = { key: 1, d: "M6 22h16", stroke: "#dc2626", "stroke-width": "2.2", "stroke-linecap": "round" }, ys = { key: 2, d: "M6 22c2-2 3-2 5 0s3 2 5 0 3-2 5 0", stroke: "#dc2626", "stroke-width": "2", "stroke-linecap": "round", fill: "none" }, Cs = { key: 3, d: "M5 14h18", stroke: "#dc2626", "stroke-width": "2.2", "stroke-linecap": "round" }, Is = { key: 2, width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "" }, Ms = /* @__PURE__ */ defineComponent({ __name: "SelectionToolbarIcons", props: { kind: {} }, setup: (e14) => (t2, a3) => "copy" === e14.kind ? (openBlock(), createElementBlock("svg", vs, [...a3[0] || (a3[0] = [createElementVNode("rect", { x: "8.5", y: "8.5", width: "11", height: "13", rx: "2.25", fill: "#f1f5f9", stroke: "#94a3b8", "stroke-width": "1.35" }, null, -1), createElementVNode("rect", { x: "4.5", y: "3.5", width: "11", height: "13", rx: "2.25", fill: "#ffffff", stroke: "#334155", "stroke-width": "1.5" }, null, -1), createElementVNode("path", { d: "M7.5 7h5.5a1.5 1.5 0 0 1 1.5 1.5V14", stroke: "#64748b", "stroke-width": "1.2", "stroke-linecap": "round" }, null, -1)])])) : "note" !== e14.kind ? (openBlock(), createElementBlock("svg", bs, ["highlight" === e14.kind ? (openBlock(), createElementBlock("rect", Ps)) : createCommentVNode("", true), a3[1] || (a3[1] = createElementVNode("text", { x: "14", y: "19", "text-anchor": "middle", "font-size": "15", "font-weight": "700", "font-family": "system-ui, -apple-system, sans-serif", fill: "#0f172a" }, " A ", -1)), "underline" === e14.kind ? (openBlock(), createElementBlock("path", ws)) : "squiggly" === e14.kind ? (openBlock(), createElementBlock("path", ys)) : "strikeout" === e14.kind ? (openBlock(), createElementBlock("path", Cs)) : createCommentVNode("", true)])) : (openBlock(), createElementBlock("svg", Is, [...a3[2] || (a3[2] = [createElementVNode("path", { d: "M8 3h8l4 4v14H8V3z", fill: "#fef3c7", stroke: "#d97706", "stroke-width": "1.2", "stroke-linejoin": "round" }, null, -1), createElementVNode("path", { d: "M16 3v4h4", stroke: "#d97706", "stroke-width": "1.2" }, null, -1), createElementVNode("path", { d: "M10 12h6M10 16h4", stroke: "#92400e", "stroke-width": "1.2", "stroke-linecap": "round" }, null, -1)])])) }), Ss = ["title", "aria-label", "onMouseenter", "onClick"], xs = ["title", "onMouseenter", "onClick"], ks = { style: { "font-size": "11px", "font-weight": "600" } }, Ls = /* @__PURE__ */ defineComponent({ __name: "SelectionToolbarCard", props: { placementAbove: { type: Boolean }, anchorHeight: {}, hiddenBuiltinActions: {}, extraActions: {}, renderCopyIcon: { type: Function } }, emits: ["action"], setup(e14, { emit: s9 }) {
|
|
4252
|
+
const i2 = e14, o = s9, r2 = [{ id: "highlight", label: "高亮背景" }, { id: "underline", label: "下划线" }, { id: "squiggly", label: "波浪线" }, { id: "strikeout", label: "删除线" }], d2 = computed(() => new Set(i2.hiddenBuiltinActions ?? [])), g2 = computed(() => !d2.value.has("copy")), m = computed(() => r2.filter((e15) => !d2.value.has(e15.id))), v = computed(() => !d2.value.has("note")), P = computed(() => [...i2.extraActions ?? []].sort((e15, t2) => (e15.order ?? 0) - (t2.order ?? 0))), w = computed(() => m.value.length > 0 || P.value.length > 0), M = ref(null), S = computed(() => ({ position: "absolute", pointerEvents: "auto", left: "50%", transform: "translateX(-50%)", top: i2.placementAbove ? void 0 : `${i2.anchorHeight + 10}px`, bottom: i2.placementAbove ? `${i2.anchorHeight + 10}px` : void 0, display: "flex", alignItems: "center", gap: "2px", padding: "4px 6px", borderRadius: "12px", background: "rgba(255, 255, 255, 0.96)", border: "1px solid rgba(15, 23, 42, 0.06)", boxShadow: "0 2px 8px rgba(15, 23, 42, 0.08), 0 12px 32px rgba(15, 23, 42, 0.1)", backdropFilter: "blur(10px)", WebkitBackdropFilter: "blur(10px)" }));
|
|
4253
|
+
function x(e15, t2 = false) {
|
|
4254
|
+
return { display: "flex", alignItems: "center", justifyContent: "center", width: "32px", height: "32px", padding: 0, margin: 0, border: "none", borderRadius: "8px", background: M.value === e15 ? t2 ? "#fffbeb" : "#f1f5f9" : "transparent", color: t2 ? "#b45309" : "#334155", cursor: "pointer", flexShrink: 0, WebkitAppearance: "none", appearance: "none" };
|
|
4255
|
+
}
|
|
4256
|
+
const k2 = { width: "1px", height: "20px", margin: "0 4px", background: "rgba(15, 23, 42, 0.1)", flexShrink: 0 };
|
|
4257
|
+
return (t2, a3) => (openBlock(), createElementBlock("div", { role: "toolbar", "aria-label": "选区工具", style: normalizeStyle(S.value) }, [g2.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("button", { type: "button", title: "复制", "aria-label": "复制", style: normalizeStyle(x("copy")), onMouseenter: a3[0] || (a3[0] = (e15) => M.value = "copy"), onMouseleave: a3[1] || (a3[1] = (e15) => M.value = null), onClick: a3[2] || (a3[2] = (e15) => o("action", "copy")) }, [e14.renderCopyIcon ? (openBlock(), createBlock(resolveDynamicComponent(e14.renderCopyIcon), { key: 0 })) : (openBlock(), createBlock(Ms, { key: 1, kind: "copy" }))], 36), w.value ? (openBlock(), createElementBlock("span", { key: 0, style: k2, "aria-hidden": "" })) : createCommentVNode("", true)], 64)) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(m.value, (e15) => (openBlock(), createElementBlock("button", { key: e15.id, type: "button", title: e15.label, "aria-label": e15.label, style: normalizeStyle(x(e15.id)), onMouseenter: (t3) => M.value = e15.id, onMouseleave: a3[3] || (a3[3] = (e16) => M.value = null), onClick: (t3) => o("action", e15.id) }, [createVNode(Ms, { kind: e15.id }, null, 8, ["kind"])], 44, Ss))), 128)), (openBlock(true), createElementBlock(Fragment, null, renderList(P.value, (e15) => (openBlock(), createElementBlock("button", { key: e15.id, type: "button", title: e15.label, style: normalizeStyle(x(e15.id)), onMouseenter: (t3) => M.value = e15.id, onMouseleave: a3[4] || (a3[4] = (e16) => M.value = null), onClick: (t3) => o("action", e15.id) }, [createElementVNode("span", ks, toDisplayString(e15.label.slice(0, 2)), 1)], 44, xs))), 128)), v.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [w.value || g2.value ? (openBlock(), createElementBlock("span", { key: 0, style: k2, "aria-hidden": "" })) : createCommentVNode("", true), createElementVNode("button", { type: "button", title: "添加笔记", "aria-label": "添加笔记", style: normalizeStyle(x("note", true)), onMouseenter: a3[5] || (a3[5] = (e15) => M.value = "note"), onMouseleave: a3[6] || (a3[6] = (e15) => M.value = null), onClick: a3[7] || (a3[7] = (e15) => o("action", "note")) }, [createVNode(Ms, { kind: "note" })], 36)], 64)) : createCommentVNode("", true)], 4));
|
|
4258
|
+
} }), $s = { highlight: "highlight", underline: "underline", squiggly: "squiggly", strikeout: "strikeout" };
|
|
4259
|
+
function Ts(e14, a3) {
|
|
4260
|
+
const s9 = computed(() => {
|
|
4261
|
+
var _a2;
|
|
4262
|
+
return (_a2 = e14()) == null ? void 0 : _a2.selectionToolbar;
|
|
4263
|
+
}), i2 = computed(() => {
|
|
4264
|
+
var _a2, _b;
|
|
4265
|
+
return false !== ((_b = (_a2 = e14()) == null ? void 0 : _a2.markup) == null ? void 0 : _b.enabled);
|
|
4266
|
+
}), o = computed(() => {
|
|
4267
|
+
var _a2, _b;
|
|
4268
|
+
return false !== ((_b = (_a2 = e14()) == null ? void 0 : _a2.notes) == null ? void 0 : _b.enabled);
|
|
4269
|
+
}), r2 = computed(() => {
|
|
4270
|
+
var _a2, _b;
|
|
4271
|
+
return !((_b = (_a2 = s9.value) == null ? void 0 : _a2.hiddenBuiltinActions) == null ? void 0 : _b.includes("copy"));
|
|
4272
|
+
}), { provides: n2 } = useCapability(SelectionPlugin.id), { provides: l } = useCapability(AnnotationPlugin.id), { provides: h2 } = useCapability(Ct$1.id);
|
|
4273
|
+
return computed(() => {
|
|
4274
|
+
var _a2, _b, _c;
|
|
4275
|
+
if (false !== ((_a2 = s9.value) == null ? void 0 : _a2.enabled) && (i2.value || o.value || r2.value || ((_c = (_b = s9.value) == null ? void 0 : _b.extraActions) == null ? void 0 : _c.length))) return (t2) => {
|
|
4276
|
+
const d2 = ds(t2.item);
|
|
4277
|
+
return (c) => {
|
|
4278
|
+
var _a3, _b2, _c2, _d;
|
|
4279
|
+
return h$1("div", c.menuWrapperProps, h$1(Ls, { placementAbove: !!((_a3 = c.placement) == null ? void 0 : _a3.suggestTop), anchorHeight: c.rect.size.height, hiddenBuiltinActions: (_b2 = s9.value) == null ? void 0 : _b2.hiddenBuiltinActions, extraActions: (_c2 = s9.value) == null ? void 0 : _c2.extraActions, renderCopyIcon: (_d = s9.value) == null ? void 0 : _d.renderCopyIcon, onAction: (s10) => {
|
|
4280
|
+
var _a4, _b3, _c3;
|
|
4281
|
+
if ("copy" !== s10) if ("highlight" !== s10 && "underline" !== s10 && "squiggly" !== s10 && "strikeout" !== s10) {
|
|
4282
|
+
if ("note" === s10) {
|
|
4283
|
+
if (!n2.value || !h2.value || !o.value) return;
|
|
4284
|
+
const e15 = n2.value.getHighlightRectsForPage(t2.item.localPageIndex, d2);
|
|
4285
|
+
return void cs(n2.value.getSelectedText(d2), (a4) => {
|
|
4286
|
+
var _a5;
|
|
4287
|
+
(_a5 = h2.value) == null ? void 0 : _a5.requestCreateFromSelection({ chapterId: t2.item.chapterId, localPageIndex: t2.item.localPageIndex, globalPageIndex: t2.item.globalPageIndex, globalPageNumber: t2.item.globalPageNumber, rectsPdfCoord: e15, selectedText: a4.join("\n") });
|
|
4288
|
+
});
|
|
4289
|
+
}
|
|
4290
|
+
(_a4 = a3 == null ? void 0 : a3.onExtraAction) == null ? void 0 : _a4.call(a3, s10, t2);
|
|
4291
|
+
} else {
|
|
4292
|
+
if (!n2.value || !l.value || !i2.value) return;
|
|
4293
|
+
xe(d2, $s[s10], l.value, n2.value, (_c3 = (_b3 = e14()) == null ? void 0 : _b3.markup) == null ? void 0 : _c3.styles);
|
|
4294
|
+
}
|
|
4295
|
+
else {
|
|
4296
|
+
if (!n2.value || !r2.value) return;
|
|
4297
|
+
cs(n2.value.getSelectedText(d2), (e15) => {
|
|
4298
|
+
!(async function(e16) {
|
|
4299
|
+
var _a5;
|
|
4300
|
+
const t3 = e16.trim();
|
|
4301
|
+
if (!t3) return false;
|
|
4302
|
+
try {
|
|
4303
|
+
if ("undefined" != typeof navigator && ((_a5 = navigator.clipboard) == null ? void 0 : _a5.writeText)) return await navigator.clipboard.writeText(t3), true;
|
|
4304
|
+
} catch {
|
|
4305
|
+
}
|
|
4306
|
+
if ("undefined" == typeof document) return false;
|
|
4307
|
+
try {
|
|
4308
|
+
const e17 = document.createElement("textarea");
|
|
4309
|
+
e17.value = t3, e17.setAttribute("readonly", ""), e17.style.position = "fixed", e17.style.left = "-9999px", document.body.appendChild(e17), e17.select();
|
|
4310
|
+
const a4 = document.execCommand("copy");
|
|
4311
|
+
return document.body.removeChild(e17), a4;
|
|
4312
|
+
} catch {
|
|
4313
|
+
return false;
|
|
4314
|
+
}
|
|
4315
|
+
})(e15.join("\n"));
|
|
4316
|
+
});
|
|
4317
|
+
}
|
|
4318
|
+
} }));
|
|
4319
|
+
};
|
|
4320
|
+
};
|
|
4321
|
+
});
|
|
4322
|
+
}
|
|
4323
|
+
const zs = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props: { className: {}, features: {}, buildSelectionMenu: {}, annotationSelectionMenu: {}, redactionSelectionMenu: {}, showNoteMarkers: { type: Boolean, default: true }, showBookmarkMarkers: { type: Boolean, default: true }, showRedactionLayer: { type: Boolean, default: false }, renderPageOverlay: {}, onExtraSelectionAction: {} }, setup(e14) {
|
|
4266
4324
|
const a3 = e14, s9 = computed(() => a3.features), { hostRef: i2 } = ya(s9), o = computed(() => {
|
|
4267
4325
|
var _a2, _b;
|
|
4268
|
-
return { background: ((_b = (_a2 = a3.features) == null ? void 0 : _a2.scrollViewport) == null ? void 0 : _b.background) ?? ye };
|
|
4326
|
+
return { background: ((_b = (_a2 = a3.features) == null ? void 0 : _a2.scrollViewport) == null ? void 0 : _b.background) ?? ye$1 };
|
|
4269
4327
|
}), r2 = (function() {
|
|
4270
4328
|
const { registry: e15 } = useRegistry();
|
|
4271
4329
|
return computed(() => {
|
|
@@ -4294,44 +4352,7 @@ const $s = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
|
|
|
4294
4352
|
}), v = computed(() => {
|
|
4295
4353
|
var _a2, _b;
|
|
4296
4354
|
return u.value && false !== ((_b = (_a2 = a3.features) == null ? void 0 : _a2.bookmarks) == null ? void 0 : _b.enabled);
|
|
4297
|
-
}), b = (
|
|
4298
|
-
const s10 = computed(() => {
|
|
4299
|
-
var _a2;
|
|
4300
|
-
return (_a2 = e15()) == null ? void 0 : _a2.selectionToolbar;
|
|
4301
|
-
}), i3 = computed(() => {
|
|
4302
|
-
var _a2, _b;
|
|
4303
|
-
return false !== ((_b = (_a2 = e15()) == null ? void 0 : _a2.markup) == null ? void 0 : _b.enabled);
|
|
4304
|
-
}), o2 = computed(() => {
|
|
4305
|
-
var _a2, _b;
|
|
4306
|
-
return false !== ((_b = (_a2 = e15()) == null ? void 0 : _a2.notes) == null ? void 0 : _b.enabled);
|
|
4307
|
-
}), { provides: r3 } = useCapability(SelectionPlugin.id), { provides: n2 } = useCapability(AnnotationPlugin.id), { provides: l } = useCapability(Ct$1.id);
|
|
4308
|
-
return computed(() => {
|
|
4309
|
-
var _a2, _b, _c;
|
|
4310
|
-
if (false !== ((_a2 = s10.value) == null ? void 0 : _a2.enabled) && (i3.value || o2.value || ((_c = (_b = s10.value) == null ? void 0 : _b.extraActions) == null ? void 0 : _c.length))) return (t2) => {
|
|
4311
|
-
const h2 = ds(t2.item);
|
|
4312
|
-
return (d2) => {
|
|
4313
|
-
var _a3, _b2, _c2;
|
|
4314
|
-
return h$1("div", d2.menuWrapperProps, h$1(ks, { placementAbove: !!((_a3 = d2.placement) == null ? void 0 : _a3.suggestTop), anchorHeight: d2.rect.size.height, hiddenBuiltinActions: (_b2 = s10.value) == null ? void 0 : _b2.hiddenBuiltinActions, extraActions: (_c2 = s10.value) == null ? void 0 : _c2.extraActions, onAction: (s11) => {
|
|
4315
|
-
var _a4, _b3, _c3;
|
|
4316
|
-
if ("highlight" !== s11 && "underline" !== s11 && "squiggly" !== s11 && "strikeout" !== s11) {
|
|
4317
|
-
if ("note" === s11) {
|
|
4318
|
-
if (!r3.value || !l.value || !o2.value) return;
|
|
4319
|
-
const e16 = r3.value.getHighlightRectsForPage(t2.item.localPageIndex, h2);
|
|
4320
|
-
return void cs(r3.value.getSelectedText(h2), (a5) => {
|
|
4321
|
-
var _a5;
|
|
4322
|
-
(_a5 = l.value) == null ? void 0 : _a5.requestCreateFromSelection({ chapterId: t2.item.chapterId, localPageIndex: t2.item.localPageIndex, globalPageIndex: t2.item.globalPageIndex, globalPageNumber: t2.item.globalPageNumber, rectsPdfCoord: e16, selectedText: a5.join("\n") });
|
|
4323
|
-
});
|
|
4324
|
-
}
|
|
4325
|
-
(_a4 = a4 == null ? void 0 : a4.onExtraAction) == null ? void 0 : _a4.call(a4, s11, t2);
|
|
4326
|
-
} else {
|
|
4327
|
-
if (!r3.value || !n2.value || !i3.value) return;
|
|
4328
|
-
xe(h2, Ls[s11], n2.value, r3.value, (_c3 = (_b3 = e15()) == null ? void 0 : _b3.markup) == null ? void 0 : _c3.styles);
|
|
4329
|
-
}
|
|
4330
|
-
} }));
|
|
4331
|
-
};
|
|
4332
|
-
};
|
|
4333
|
-
});
|
|
4334
|
-
})(() => a3.features, { onExtraAction: a3.onExtraSelectionAction }), C = computed(() => {
|
|
4355
|
+
}), b = Ts(() => a3.features, { onExtraAction: a3.onExtraSelectionAction }), C = computed(() => {
|
|
4335
4356
|
if (a3.buildSelectionMenu || b.value) return (e15) => {
|
|
4336
4357
|
const t2 = b.value ? b.value(e15) : e15.defaultMenu;
|
|
4337
4358
|
return a3.buildSelectionMenu ? a3.buildSelectionMenu({ ...e15, defaultMenu: t2 }) : t2;
|
|
@@ -4355,22 +4376,22 @@ const $s = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
|
|
|
4355
4376
|
var _a2, _b, _c, _d;
|
|
4356
4377
|
return [createVNode(fs, { item: t3, features: e14.features, "show-note-markers": p2.value, "show-bookmark-markers": f.value, "show-redaction-layer": e14.showRedactionLayer, "note-marker-ui": (_b = (_a2 = e14.features) == null ? void 0 : _a2.notes) == null ? void 0 : _b.marker, "bookmark-marker-ui": (_d = (_c = e14.features) == null ? void 0 : _c.bookmarks) == null ? void 0 : _d.marker, "build-selection-menu": C.value, "create-note": unref(r2), "annotation-selection-menu": e14.annotationSelectionMenu, "redaction-selection-menu": e14.redactionSelectionMenu, "render-page-overlay": x }, null, 8, ["item", "features", "show-note-markers", "show-bookmark-markers", "show-redaction-layer", "note-marker-ui", "bookmark-marker-ui", "build-selection-menu", "create-note", "annotation-selection-menu", "redaction-selection-menu"])];
|
|
4357
4378
|
}), _: 1 }, 8, ["class", "style"]), renderSlot(t2.$slots, "default")], 6));
|
|
4358
|
-
} }),
|
|
4379
|
+
} }), Ds = { key: 0, style: { display: "flex", flexDirection: "column", height: "100%", minHeight: 0, width: "100%" } }, Os = /* @__PURE__ */ defineComponent({ __name: "ChapterPdfViewer", props: { engine: {}, options: {}, editorOptions: {}, features: {}, className: {}, viewportClassName: {}, onExtraSelectionAction: { type: Function } }, setup(e14) {
|
|
4359
4380
|
const a3 = e14, s9 = computed(() => (function(e15) {
|
|
4360
4381
|
if (e15.options) return da(e15.options);
|
|
4361
4382
|
if (!e15.editorOptions) throw new Error("ChapterPdfViewer: 请传入 `options`(推荐),或同时传入 `editorOptions` 与 `features`");
|
|
4362
4383
|
const t2 = $e(e15.features), { plugins: a4 } = ra({ ...e15.editorOptions, features: t2 });
|
|
4363
4384
|
return { plugins: a4, features: t2, editorOptions: { ...e15.editorOptions, features: t2 } };
|
|
4364
4385
|
})({ engine: a3.engine, options: a3.options, editorOptions: a3.editorOptions, features: a3.features }));
|
|
4365
|
-
return (t2, a4) => (openBlock(), createElementBlock("div", { class: normalizeClass(e14.className), style: normalizeStyle(e14.className ? void 0 : unref(be$1)) }, [createVNode(unref(EmbedPDF), { engine: e14.engine, plugins: s9.value.plugins }, { default: withCtx(({ pluginsReady: a5 }) => [a5 ? (openBlock(), createElementBlock("div",
|
|
4366
|
-
} }),
|
|
4386
|
+
return (t2, a4) => (openBlock(), createElementBlock("div", { class: normalizeClass(e14.className), style: normalizeStyle(e14.className ? void 0 : unref(be$1)) }, [createVNode(unref(EmbedPDF), { engine: e14.engine, plugins: s9.value.plugins }, { default: withCtx(({ pluginsReady: a5 }) => [a5 ? (openBlock(), createElementBlock("div", Ds, [renderSlot(t2.$slots, "prepend"), createVNode(zs, { class: normalizeClass(e14.viewportClassName), style: { flex: 1, minHeight: 0 }, features: s9.value.features, "on-extra-selection-action": e14.onExtraSelectionAction }, null, 8, ["class", "features", "on-extra-selection-action"]), renderSlot(t2.$slots, "default")])) : createCommentVNode("", true)]), _: 3 }, 8, ["engine", "plugins"])], 6));
|
|
4387
|
+
} }), Gs = { class: "chapter-tree-row" }, Ns = ["aria-expanded"], As = { key: 1, class: "chapter-tree-toggle-spacer", "aria-hidden": "" }, Vs = { class: "chapter-tree-label" }, Es = { class: "chapter-tree-meta" }, _s = { key: 0 }, Rs = (e14, t2) => {
|
|
4367
4388
|
const a3 = e14.__vccOpts || e14;
|
|
4368
4389
|
for (const [s9, i2] of t2) a3[s9] = i2;
|
|
4369
4390
|
return a3;
|
|
4370
|
-
},
|
|
4391
|
+
}, Fs = /* @__PURE__ */ Rs(/* @__PURE__ */ defineComponent({ __name: "ChapterTreeItem", props: { node: {}, depth: {}, activeChapterId: {}, chapterStatus: {} }, emits: ["select"], setup(e14) {
|
|
4371
4392
|
const s9 = { idle: "未加载", loading: "加载中", loaded: "已加载", closed: "已卸载", error: "失败", "password-required": "需密码" }, i2 = e14, o = computed(() => i2.node.children ?? []), r2 = computed(() => o.value.length > 0), h2 = ref(i2.depth < 1), u = computed(() => i2.activeChapterId === i2.node.id), p2 = computed(() => i2.chapterStatus[i2.node.id] ?? "idle"), g2 = computed(() => !r2.value);
|
|
4372
|
-
return (t2, a3) => (openBlock(), createElementBlock("li", null, [createElementVNode("div",
|
|
4373
|
-
} }), [["__scopeId", "data-v-315bbf7a"]]),
|
|
4393
|
+
return (t2, a3) => (openBlock(), createElementBlock("li", null, [createElementVNode("div", Gs, [r2.value ? (openBlock(), createElementBlock("button", { key: 0, type: "button", class: "chapter-tree-toggle", "aria-expanded": h2.value, onClick: a3[0] || (a3[0] = (e15) => h2.value = !h2.value) }, toDisplayString(h2.value ? "▼" : "▶"), 9, Ns)) : (openBlock(), createElementBlock("span", As)), createElementVNode("button", { type: "button", class: normalizeClass(["chapter-tree-btn", { "chapter-tree-btn-active": u.value }]), onClick: a3[1] || (a3[1] = (a4) => t2.$emit("select", e14.node.id)) }, [createElementVNode("div", Vs, toDisplayString(e14.node.title), 1), createElementVNode("div", Es, [createElementVNode("span", null, " 第 " + toDisplayString(e14.node.startPage) + toDisplayString(e14.node.endPage !== e14.node.startPage ? `–${e14.node.endPage}` : "") + " 页 ", 1), g2.value ? (openBlock(), createElementBlock("span", _s, toDisplayString(s9[p2.value]), 1)) : createCommentVNode("", true)])], 2)]), r2.value && h2.value ? (openBlock(), createBlock(Us, { key: 0, nodes: o.value, depth: e14.depth + 1, "active-chapter-id": e14.activeChapterId, "chapter-status": e14.chapterStatus, onSelect: a3[2] || (a3[2] = (e15) => t2.$emit("select", e15)) }, null, 8, ["nodes", "depth", "active-chapter-id", "chapter-status"])) : createCommentVNode("", true)]));
|
|
4394
|
+
} }), [["__scopeId", "data-v-315bbf7a"]]), Us = /* @__PURE__ */ Rs(/* @__PURE__ */ defineComponent({ __name: "ChapterTreeList", props: { nodes: {}, depth: {}, activeChapterId: {}, chapterStatus: {} }, emits: ["select"], setup: (e14) => (t2, a3) => (openBlock(), createElementBlock("ul", { class: "chapter-tree-list", style: normalizeStyle({ marginLeft: e14.depth > 0 ? "12px" : "0" }) }, [(openBlock(true), createElementBlock(Fragment, null, renderList(e14.nodes, (s9) => (openBlock(), createBlock(Fs, { key: s9.id, node: s9, depth: e14.depth, "active-chapter-id": e14.activeChapterId, "chapter-status": e14.chapterStatus, onSelect: a3[0] || (a3[0] = (e15) => t2.$emit("select", e15)) }, null, 8, ["node", "depth", "active-chapter-id", "chapter-status"]))), 128))], 4)) }), [["__scopeId", "data-v-eb742e4f"]]), qs = { class: "chapter-tree" }, Ws = { class: "chapter-tree-nav", "aria-label": "章节目录" }, Hs = /* @__PURE__ */ Rs(/* @__PURE__ */ defineComponent({ __name: "ChapterTreePanel", props: { tree: {}, activeChapterId: {} }, emits: ["active-chapter-change"], setup(e14, { emit: t2 }) {
|
|
4374
4395
|
const o = e14, r2 = t2, { provides: h2 } = useCapability(at$1.id), { provides: d2 } = useCapability(We.id), u = ref({});
|
|
4375
4396
|
function p2() {
|
|
4376
4397
|
if (!d2.value) return;
|
|
@@ -4388,7 +4409,7 @@ const $s = /* @__PURE__ */ defineComponent({ __name: "PdfChapterViewport", props
|
|
|
4388
4409
|
}
|
|
4389
4410
|
return watch(d2, (e15) => {
|
|
4390
4411
|
g2 == null ? void 0 : g2(), g2 = e15 ? e15.onChapterStatusChange(p2) : null;
|
|
4391
|
-
}, { immediate: true }), onBeforeUnmount(() => g2 == null ? void 0 : g2()), (t3, a3) => (openBlock(), createElementBlock("aside",
|
|
4412
|
+
}, { immediate: true }), onBeforeUnmount(() => g2 == null ? void 0 : g2()), (t3, a3) => (openBlock(), createElementBlock("aside", qs, [a3[0] || (a3[0] = createElementVNode("h2", { class: "chapter-tree-title" }, "章节目录", -1)), createElementVNode("nav", Ws, [createVNode(Us, { nodes: e14.tree, depth: 0, "active-chapter-id": e14.activeChapterId, "chapter-status": u.value, onSelect: f }, null, 8, ["nodes", "active-chapter-id", "chapter-status"])])]));
|
|
4392
4413
|
} }), [["__scopeId", "data-v-d7a0838d"]]);
|
|
4393
4414
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4394
4415
|
__name: "ChapterPdfViewer",
|
|
@@ -4402,7 +4423,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
4402
4423
|
},
|
|
4403
4424
|
setup(__props) {
|
|
4404
4425
|
return (_ctx, _cache) => {
|
|
4405
|
-
return openBlock(), createBlock(unref(
|
|
4426
|
+
return openBlock(), createBlock(unref(Os), normalizeProps(guardReactiveProps(_ctx.$props)), createSlots({
|
|
4406
4427
|
default: withCtx(() => [
|
|
4407
4428
|
renderSlot(_ctx.$slots, "default")
|
|
4408
4429
|
]),
|
|
@@ -7186,21 +7207,21 @@ function Bt(t2) {
|
|
|
7186
7207
|
}
|
|
7187
7208
|
PdfAnnotationSubtype.HIGHLIGHT, PdfAnnotationSubtype.UNDERLINE, PdfAnnotationSubtype.SQUIGGLY, PdfAnnotationSubtype.STRIKEOUT, PdfAnnotationSubtype.HIGHLIGHT, PdfAnnotationSubtype.UNDERLINE, PdfAnnotationSubtype.SQUIGGLY, PdfAnnotationSubtype.STRIKEOUT;
|
|
7188
7209
|
Bt();
|
|
7189
|
-
const
|
|
7190
|
-
function
|
|
7210
|
+
const oe = 1;
|
|
7211
|
+
function re(t2) {
|
|
7191
7212
|
const e14 = new Uint8Array(t2);
|
|
7192
7213
|
let a3 = "";
|
|
7193
7214
|
for (let s9 = 0; s9 < e14.length; s9++) a3 += String.fromCharCode(e14[s9]);
|
|
7194
7215
|
return btoa(a3);
|
|
7195
7216
|
}
|
|
7196
|
-
function
|
|
7217
|
+
function ie(t2) {
|
|
7197
7218
|
return t2.map((t3) => {
|
|
7198
7219
|
if (!(t3.ctx && "data" in t3.ctx && t3.ctx.data instanceof ArrayBuffer)) return { annotation: t3.annotation };
|
|
7199
7220
|
const e14 = t3.ctx;
|
|
7200
|
-
return { annotation: t3.annotation, ctx: { dataBase64:
|
|
7221
|
+
return { annotation: t3.annotation, ctx: { dataBase64: re(e14.data), mimeType: e14.mimeType } };
|
|
7201
7222
|
});
|
|
7202
7223
|
}
|
|
7203
|
-
function
|
|
7224
|
+
function ne(t2) {
|
|
7204
7225
|
return t2.map((t3) => {
|
|
7205
7226
|
var _a2;
|
|
7206
7227
|
if (!((_a2 = t3.ctx) == null ? void 0 : _a2.dataBase64)) return { annotation: t3.annotation };
|
|
@@ -7212,21 +7233,21 @@ function ie(t2) {
|
|
|
7212
7233
|
return { annotation: t3.annotation, ctx: { data: e14, ...t3.ctx.mimeType ? { mimeType: t3.ctx.mimeType } : {} } };
|
|
7213
7234
|
});
|
|
7214
7235
|
}
|
|
7215
|
-
function
|
|
7236
|
+
function he(t2) {
|
|
7216
7237
|
return { bookmarks: false !== (t2 == null ? void 0 : t2.bookmarks), notes: false !== (t2 == null ? void 0 : t2.notes), markup: false !== (t2 == null ? void 0 : t2.markup) };
|
|
7217
7238
|
}
|
|
7218
|
-
function
|
|
7239
|
+
function de(t2) {
|
|
7219
7240
|
var _a2, _b, _c, _d;
|
|
7220
7241
|
const e14 = (_a2 = t2.getPlugin(AnnotationPlugin.id)) == null ? void 0 : _a2.provides(), a3 = (_b = t2.getPlugin(lt2.id)) == null ? void 0 : _b.provides(), s9 = (_c = t2.getPlugin(At.id)) == null ? void 0 : _c.provides(), o = (_d = t2.getPlugin(O.id)) == null ? void 0 : _d.provides();
|
|
7221
7242
|
return { annotation: e14, note: a3, bookmark: s9, chapterManager: o };
|
|
7222
7243
|
}
|
|
7223
|
-
async function
|
|
7244
|
+
async function le(t2, e14, a3) {
|
|
7224
7245
|
if (!a3 || !t2) return;
|
|
7225
7246
|
const s9 = await t2.ensureChapterLoaded(e14);
|
|
7226
7247
|
if ("loaded" !== s9) throw new Error(`章节 ${e14} 未加载成功(${s9}),无法导入/导出划线`);
|
|
7227
7248
|
}
|
|
7228
|
-
async function
|
|
7229
|
-
const s9 =
|
|
7249
|
+
async function ce(t2, e14, a3) {
|
|
7250
|
+
const s9 = he(a3), { annotation: o, note: r2, bookmark: i2, chapterManager: n2 } = de(t2), h2 = { chapterId: e14 };
|
|
7230
7251
|
if (s9.bookmarks) {
|
|
7231
7252
|
if (!i2) throw new Error("paragraph-bookmark 插件未注册");
|
|
7232
7253
|
h2.bookmarks = i2.listBookmarksForChapter(e14);
|
|
@@ -7237,25 +7258,25 @@ async function le(t2, e14, a3) {
|
|
|
7237
7258
|
}
|
|
7238
7259
|
if (s9.markup) {
|
|
7239
7260
|
if (!o) throw new Error("annotation 插件未注册");
|
|
7240
|
-
await
|
|
7261
|
+
await le(n2, e14, false !== (a3 == null ? void 0 : a3.ensureChapterLoaded));
|
|
7241
7262
|
const t3 = await (d2 = o.forDocument(e14).exportAnnotations(), new Promise((t4, e15) => {
|
|
7242
7263
|
d2.wait((e16) => t4(e16), (t5) => e15(t5));
|
|
7243
7264
|
}));
|
|
7244
|
-
h2.markup =
|
|
7265
|
+
h2.markup = ie(t3);
|
|
7245
7266
|
}
|
|
7246
7267
|
var d2;
|
|
7247
7268
|
return h2;
|
|
7248
7269
|
}
|
|
7249
|
-
async function
|
|
7270
|
+
async function ue(t2, e14, a3) {
|
|
7250
7271
|
const s9 = {};
|
|
7251
7272
|
for (const o of e14.chapters) {
|
|
7252
|
-
const e15 = await
|
|
7273
|
+
const e15 = await ce(t2, o.chapterId, a3), { chapterId: r2, ...i2 } = e15;
|
|
7253
7274
|
s9[o.chapterId] = i2;
|
|
7254
7275
|
}
|
|
7255
7276
|
return { version: 1, exportedAt: /* @__PURE__ */ (/* @__PURE__ */ new Date()).toISOString(), chapters: s9 };
|
|
7256
7277
|
}
|
|
7257
|
-
async function
|
|
7258
|
-
const s9 =
|
|
7278
|
+
async function pe(t2, e14, a3) {
|
|
7279
|
+
const s9 = he(a3), o = (a3 == null ? void 0 : a3.mode) ?? "replace", { annotation: r2, note: i2, bookmark: n2, chapterManager: h2 } = de(t2), d2 = e14.chapterId;
|
|
7259
7280
|
if (s9.bookmarks && e14.bookmarks) {
|
|
7260
7281
|
if (!n2) throw new Error("paragraph-bookmark 插件未注册");
|
|
7261
7282
|
if ("replace" === o) n2.replaceBookmarksForChapter(d2, e14.bookmarks);
|
|
@@ -7268,41 +7289,41 @@ async function ue(t2, e14, a3) {
|
|
|
7268
7289
|
}
|
|
7269
7290
|
if (s9.markup && e14.markup) {
|
|
7270
7291
|
if (!r2) throw new Error("annotation 插件未注册");
|
|
7271
|
-
await
|
|
7272
|
-
const t3 = r2.forDocument(d2), s10 =
|
|
7292
|
+
await le(h2, d2, false !== (a3 == null ? void 0 : a3.ensureChapterLoaded));
|
|
7293
|
+
const t3 = r2.forDocument(d2), s10 = ne(e14.markup);
|
|
7273
7294
|
"replace" === o && t3.deleteAllAnnotations(), t3.importAnnotations(s10);
|
|
7274
7295
|
}
|
|
7275
7296
|
(a3 == null ? void 0 : a3.persistNotes) && i2 && await a3.persistNotes(i2.listAllNotes()), (a3 == null ? void 0 : a3.persistBookmarks) && n2 && await a3.persistBookmarks(n2.listBookmarks());
|
|
7276
7297
|
}
|
|
7277
|
-
async function
|
|
7298
|
+
async function ge(t2, e14, a3) {
|
|
7278
7299
|
if (1 !== e14.version) throw new Error(`不支持的归档版本 ${e14.version},当前为 1`);
|
|
7279
|
-
for (const [s9, o] of Object.entries(e14.chapters)) await
|
|
7300
|
+
for (const [s9, o] of Object.entries(e14.chapters)) await pe(t2, { chapterId: s9, ...o }, a3);
|
|
7280
7301
|
}
|
|
7281
|
-
function
|
|
7302
|
+
function fe(t2) {
|
|
7282
7303
|
return JSON.stringify(t2, null, 2);
|
|
7283
7304
|
}
|
|
7284
|
-
function
|
|
7305
|
+
function me(t2) {
|
|
7285
7306
|
const e14 = JSON.parse(t2);
|
|
7286
7307
|
if (!e14 || "object" != typeof e14 || !e14.chapters) throw new Error("无效的章节标注 JSON");
|
|
7287
7308
|
return e14;
|
|
7288
7309
|
}
|
|
7289
|
-
function
|
|
7310
|
+
function ve(t2) {
|
|
7290
7311
|
return JSON.stringify(t2, null, 2);
|
|
7291
7312
|
}
|
|
7292
|
-
function
|
|
7313
|
+
function be(t2) {
|
|
7293
7314
|
const e14 = JSON.parse(t2);
|
|
7294
7315
|
if (!(e14 == null ? void 0 : e14.chapterId)) throw new Error("无效的章节标注 JSON:缺少 chapterId");
|
|
7295
7316
|
return e14;
|
|
7296
7317
|
}
|
|
7297
|
-
function
|
|
7318
|
+
function Pe(t2, e14) {
|
|
7298
7319
|
const a3 = new Blob([e14], { type: "application/json;charset=utf-8" }), s9 = URL.createObjectURL(a3), o = document.createElement("a");
|
|
7299
7320
|
o.href = s9, o.download = t2, o.click(), URL.revokeObjectURL(s9);
|
|
7300
7321
|
}
|
|
7301
|
-
function
|
|
7302
|
-
|
|
7322
|
+
function we(t2, e14 = "chapter-annotations.json") {
|
|
7323
|
+
Pe(e14, fe(t2));
|
|
7303
7324
|
}
|
|
7304
|
-
function
|
|
7305
|
-
|
|
7325
|
+
function ye(t2, e14) {
|
|
7326
|
+
Pe(e14 ?? `chapter-annotations-${t2.chapterId}.json`, ve(t2));
|
|
7306
7327
|
}
|
|
7307
7328
|
const t = { kind: "first-wins" };
|
|
7308
7329
|
function i(e14) {
|
|
@@ -7329,37 +7350,37 @@ function d(e14) {
|
|
|
7329
7350
|
return { tree: g(e14), manifest: { chapters: p(e14) } };
|
|
7330
7351
|
}
|
|
7331
7352
|
export {
|
|
7332
|
-
|
|
7353
|
+
oe as CHAPTER_ANNOTATIONS_ARCHIVE_VERSION,
|
|
7333
7354
|
ze as CallbackPasswordProvider,
|
|
7334
7355
|
ChapterManagerPlugin,
|
|
7335
7356
|
_sfc_main as ChapterPdfViewer,
|
|
7336
|
-
|
|
7357
|
+
Hs as ChapterTreePanel,
|
|
7337
7358
|
oa as DEFAULT_CHAPTER_VIEWER_CONFIG,
|
|
7338
7359
|
ia as DEFAULT_CHAPTER_VIEWER_FEATURES,
|
|
7339
7360
|
EmbedPDF2 as EmbedPDF,
|
|
7340
|
-
|
|
7361
|
+
zs as PdfChapterViewport,
|
|
7341
7362
|
xe as applySelectionMarkup,
|
|
7342
7363
|
d as buildChapterViewerCatalog,
|
|
7343
7364
|
Bt$1 as buildParagraphBookmarkAnchor,
|
|
7344
|
-
|
|
7345
|
-
|
|
7365
|
+
fe as chapterAnnotationsArchiveToJson,
|
|
7366
|
+
ve as chapterAnnotationsSnapshotToJson,
|
|
7346
7367
|
h as chapterDescriptorFromTreeNode,
|
|
7347
7368
|
da as createChapterViewerBundle,
|
|
7348
7369
|
ra as createChapterViewerEditor,
|
|
7349
7370
|
ca as createChapterViewerEditorOptions,
|
|
7350
7371
|
aa as createPdfChapterEditor,
|
|
7351
7372
|
t as defaultOverlapStrategy,
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7373
|
+
we as downloadChapterAnnotationsArchive,
|
|
7374
|
+
ye as downloadChapterAnnotationsSnapshot,
|
|
7375
|
+
Pe as downloadJsonFile,
|
|
7376
|
+
ue as exportAllChapterAnnotations,
|
|
7377
|
+
ce as exportChapterAnnotations,
|
|
7357
7378
|
p as flattenChapterTree,
|
|
7358
|
-
|
|
7359
|
-
|
|
7379
|
+
pe as importChapterAnnotations,
|
|
7380
|
+
ge as importChapterAnnotationsArchive,
|
|
7360
7381
|
i as overlapStrategyForSamePageOwner,
|
|
7361
|
-
|
|
7362
|
-
|
|
7382
|
+
me as parseChapterAnnotationsArchiveJson,
|
|
7383
|
+
be as parseChapterAnnotationsSnapshotJson,
|
|
7363
7384
|
g as toChapterTreeNodes,
|
|
7364
7385
|
useCapability2 as useCapability,
|
|
7365
7386
|
usePdfiumEngine,
|