jit-viewer 1.0.8 → 1.1.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/dist/index.js CHANGED
@@ -21,7 +21,18 @@ const EXTENSION_MAP = {
21
21
  "markdown": "markdown",
22
22
  "ofd": "ofd",
23
23
  "html": "html",
24
- "htm": "html"
24
+ "htm": "html",
25
+ // 图片格式
26
+ "jpg": "image",
27
+ "jpeg": "image",
28
+ "png": "image",
29
+ "gif": "image",
30
+ "webp": "image",
31
+ "svg": "image",
32
+ "bmp": "image",
33
+ "tiff": "image",
34
+ "tif": "image",
35
+ "ico": "image"
25
36
  };
26
37
  const MIME_MAP = {
27
38
  "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
@@ -35,7 +46,17 @@ const MIME_MAP = {
35
46
  "text/x-markdown": "md",
36
47
  "application/ofd": "ofd",
37
48
  "text/html": "html",
38
- "application/xhtml+xml": "html"
49
+ "application/xhtml+xml": "html",
50
+ // 图片 MIME 类型
51
+ "image/jpeg": "image",
52
+ "image/png": "image",
53
+ "image/gif": "image",
54
+ "image/webp": "image",
55
+ "image/svg+xml": "image",
56
+ "image/bmp": "image",
57
+ "image/tiff": "image",
58
+ "image/x-icon": "image",
59
+ "image/vnd.microsoft.icon": "image"
39
60
  };
40
61
  function getFileExtension(filename) {
41
62
  const match = filename.toLowerCase().match(/\.([a-z0-9]+)$/);
@@ -13834,13 +13855,13 @@ function useViewerState() {
13834
13855
  }
13835
13856
  return context;
13836
13857
  }
13837
- const _hoisted_1$b = ["disabled", "title"];
13838
- const _hoisted_2$7 = { class: "jv-toolbar-btn__icon" };
13839
- const _hoisted_3$2 = {
13858
+ const _hoisted_1$c = ["disabled", "title"];
13859
+ const _hoisted_2$8 = { class: "jv-toolbar-btn__icon" };
13860
+ const _hoisted_3$3 = {
13840
13861
  key: 0,
13841
13862
  class: "jv-toolbar-btn__label"
13842
13863
  };
13843
- const _sfc_main$e = /* @__PURE__ */ defineComponent({
13864
+ const _sfc_main$f = /* @__PURE__ */ defineComponent({
13844
13865
  __name: "ActionButton",
13845
13866
  props: {
13846
13867
  type: {},
@@ -13864,11 +13885,11 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
13864
13885
  title: __props.title,
13865
13886
  onClick: handleClick
13866
13887
  }, [
13867
- createBaseVNode("span", _hoisted_2$7, [
13888
+ createBaseVNode("span", _hoisted_2$8, [
13868
13889
  renderSlot(_ctx.$slots, "default", {}, void 0, true)
13869
13890
  ]),
13870
- __props.label ? (openBlock(), createElementBlock("span", _hoisted_3$2, toDisplayString(__props.label), 1)) : createCommentVNode("", true)
13871
- ], 10, _hoisted_1$b);
13891
+ __props.label ? (openBlock(), createElementBlock("span", _hoisted_3$3, toDisplayString(__props.label), 1)) : createCommentVNode("", true)
13892
+ ], 10, _hoisted_1$c);
13872
13893
  };
13873
13894
  }
13874
13895
  });
@@ -13879,11 +13900,11 @@ const _export_sfc = (sfc, props) => {
13879
13900
  }
13880
13901
  return target;
13881
13902
  };
13882
- const ActionButton = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-9abd52f0"]]);
13883
- const _hoisted_1$a = { class: "jv-zoom-control" };
13884
- const _hoisted_2$6 = { class: "jv-zoom-control__value" };
13903
+ const ActionButton = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-9abd52f0"]]);
13904
+ const _hoisted_1$b = { class: "jv-zoom-control" };
13905
+ const _hoisted_2$7 = { class: "jv-zoom-control__value" };
13885
13906
  const ZOOM_STEP = 0.1;
13886
- const _sfc_main$d = /* @__PURE__ */ defineComponent({
13907
+ const _sfc_main$e = /* @__PURE__ */ defineComponent({
13887
13908
  __name: "ZoomControl",
13888
13909
  setup(__props) {
13889
13910
  const { t } = useLocale();
@@ -13898,7 +13919,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
13898
13919
  resetTransform();
13899
13920
  }
13900
13921
  return (_ctx, _cache) => {
13901
- return openBlock(), createElementBlock("div", _hoisted_1$a, [
13922
+ return openBlock(), createElementBlock("div", _hoisted_1$b, [
13902
13923
  createVNode(ActionButton, {
13903
13924
  type: "zoom-out",
13904
13925
  title: unref(t)("toolbar.zoomOut"),
@@ -13932,7 +13953,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
13932
13953
  ])]),
13933
13954
  _: 1
13934
13955
  }, 8, ["title"]),
13935
- createBaseVNode("span", _hoisted_2$6, toDisplayString(Math.round(unref(zoom) * 100)) + "%", 1),
13956
+ createBaseVNode("span", _hoisted_2$7, toDisplayString(Math.round(unref(zoom) * 100)) + "%", 1),
13936
13957
  createVNode(ActionButton, {
13937
13958
  type: "zoom-in",
13938
13959
  title: unref(t)("toolbar.zoomIn"),
@@ -14006,10 +14027,10 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
14006
14027
  };
14007
14028
  }
14008
14029
  });
14009
- const ZoomControl = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-874ddbac"]]);
14010
- const _hoisted_1$9 = { class: "jv-rotate-control" };
14030
+ const ZoomControl = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-874ddbac"]]);
14031
+ const _hoisted_1$a = { class: "jv-rotate-control" };
14011
14032
  const ROTATE_STEP = 90;
14012
- const _sfc_main$c = /* @__PURE__ */ defineComponent({
14033
+ const _sfc_main$d = /* @__PURE__ */ defineComponent({
14013
14034
  __name: "RotateControl",
14014
14035
  setup(__props) {
14015
14036
  const { t } = useLocale();
@@ -14021,7 +14042,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
14021
14042
  setRotate(ROTATE_STEP);
14022
14043
  }
14023
14044
  return (_ctx, _cache) => {
14024
- return openBlock(), createElementBlock("div", _hoisted_1$9, [
14045
+ return openBlock(), createElementBlock("div", _hoisted_1$a, [
14025
14046
  createVNode(ActionButton, {
14026
14047
  type: "rotate-left",
14027
14048
  title: unref(t)("toolbar.rotateLeft"),
@@ -14060,22 +14081,22 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
14060
14081
  };
14061
14082
  }
14062
14083
  });
14063
- const RotateControl = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-ad291658"]]);
14064
- const _hoisted_1$8 = {
14084
+ const RotateControl = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-ad291658"]]);
14085
+ const _hoisted_1$9 = {
14065
14086
  key: 0,
14066
14087
  viewBox: "0 0 24 24",
14067
14088
  fill: "none",
14068
14089
  stroke: "currentColor",
14069
14090
  "stroke-width": "2"
14070
14091
  };
14071
- const _hoisted_2$5 = {
14092
+ const _hoisted_2$6 = {
14072
14093
  key: 1,
14073
14094
  viewBox: "0 0 24 24",
14074
14095
  fill: "none",
14075
14096
  stroke: "currentColor",
14076
14097
  "stroke-width": "2"
14077
14098
  };
14078
- const _sfc_main$b = /* @__PURE__ */ defineComponent({
14099
+ const _sfc_main$c = /* @__PURE__ */ defineComponent({
14079
14100
  __name: "FullscreenButton",
14080
14101
  setup(__props) {
14081
14102
  const { t } = useLocale();
@@ -14104,9 +14125,9 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
14104
14125
  onClick: toggleFullscreen
14105
14126
  }, {
14106
14127
  default: withCtx(() => [
14107
- !isFullscreen.value ? (openBlock(), createElementBlock("svg", _hoisted_1$8, [..._cache[0] || (_cache[0] = [
14128
+ !isFullscreen.value ? (openBlock(), createElementBlock("svg", _hoisted_1$9, [..._cache[0] || (_cache[0] = [
14108
14129
  createBaseVNode("path", { d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" }, null, -1)
14109
- ])])) : (openBlock(), createElementBlock("svg", _hoisted_2$5, [..._cache[1] || (_cache[1] = [
14130
+ ])])) : (openBlock(), createElementBlock("svg", _hoisted_2$6, [..._cache[1] || (_cache[1] = [
14110
14131
  createBaseVNode("path", { d: "M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3" }, null, -1)
14111
14132
  ])]))
14112
14133
  ]),
@@ -14115,18 +14136,18 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
14115
14136
  };
14116
14137
  }
14117
14138
  });
14118
- const _hoisted_1$7 = {
14139
+ const _hoisted_1$8 = {
14119
14140
  key: 0,
14120
14141
  class: "jv-pagination"
14121
14142
  };
14122
- const _hoisted_2$4 = { class: "jv-pagination__info" };
14123
- const _sfc_main$a = /* @__PURE__ */ defineComponent({
14143
+ const _hoisted_2$5 = { class: "jv-pagination__info" };
14144
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
14124
14145
  __name: "Pagination",
14125
14146
  setup(__props) {
14126
14147
  const { t } = useLocale();
14127
14148
  const { currentPage, totalPages, prevPage, nextPage } = useViewerState();
14128
14149
  return (_ctx, _cache) => {
14129
- return unref(totalPages) > 1 ? (openBlock(), createElementBlock("div", _hoisted_1$7, [
14150
+ return unref(totalPages) > 1 ? (openBlock(), createElementBlock("div", _hoisted_1$8, [
14130
14151
  createVNode(ActionButton, {
14131
14152
  type: "prev",
14132
14153
  title: unref(t)("toolbar.prevPage"),
@@ -14145,7 +14166,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
14145
14166
  ])]),
14146
14167
  _: 1
14147
14168
  }, 8, ["title", "disabled", "onClick"]),
14148
- createBaseVNode("span", _hoisted_2$4, toDisplayString(unref(t)("toolbar.pageInfo", { current: unref(currentPage).toString(), total: unref(totalPages).toString() })), 1),
14169
+ createBaseVNode("span", _hoisted_2$5, toDisplayString(unref(t)("toolbar.pageInfo", { current: unref(currentPage).toString(), total: unref(totalPages).toString() })), 1),
14149
14170
  createVNode(ActionButton, {
14150
14171
  type: "next",
14151
14172
  title: unref(t)("toolbar.nextPage"),
@@ -14168,17 +14189,17 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
14168
14189
  };
14169
14190
  }
14170
14191
  });
14171
- const Pagination = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-97c0759f"]]);
14172
- const _hoisted_1$6 = {
14192
+ const Pagination = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-97c0759f"]]);
14193
+ const _hoisted_1$7 = {
14173
14194
  key: 0,
14174
14195
  class: "jv-toolbar__top"
14175
14196
  };
14176
- const _hoisted_2$3 = { class: "jv-toolbar__left" };
14177
- const _hoisted_3$1 = {
14197
+ const _hoisted_2$4 = { class: "jv-toolbar__left" };
14198
+ const _hoisted_3$2 = {
14178
14199
  key: 0,
14179
14200
  class: "jv-toolbar__filename"
14180
14201
  };
14181
- const _hoisted_4$1 = { class: "jv-toolbar__center" };
14202
+ const _hoisted_4$2 = { class: "jv-toolbar__center" };
14182
14203
  const _hoisted_5$1 = { class: "jv-toolbar__right" };
14183
14204
  const _hoisted_6$1 = {
14184
14205
  key: 1,
@@ -14187,7 +14208,7 @@ const _hoisted_6$1 = {
14187
14208
  const _hoisted_7$1 = { class: "jv-toolbar__left" };
14188
14209
  const _hoisted_8$1 = { class: "jv-toolbar__center" };
14189
14210
  const _hoisted_9 = { class: "jv-toolbar__right" };
14190
- const _sfc_main$9 = /* @__PURE__ */ defineComponent({
14211
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
14191
14212
  __name: "Toolbar",
14192
14213
  props: {
14193
14214
  config: {},
@@ -14197,145 +14218,6 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
14197
14218
  const props = __props;
14198
14219
  const { t } = useLocale();
14199
14220
  const { filename, fileSource } = useViewerState();
14200
- const brandingRef = /* @__PURE__ */ ref();
14201
- let viewerRoot = null;
14202
- let copyrightObserver = null;
14203
- let copyrightCheckInterval = null;
14204
- function checkCopyright() {
14205
- const branding = brandingRef.value;
14206
- if (!branding) return false;
14207
- if (!viewerRoot) {
14208
- viewerRoot = branding.closest(".jv-viewer");
14209
- }
14210
- if (!viewerRoot || !document.body.contains(viewerRoot)) {
14211
- return false;
14212
- }
14213
- if (!viewerRoot.contains(branding)) {
14214
- showCopyrightWarning();
14215
- return false;
14216
- }
14217
- const link = branding.querySelector(".jv-branding-link");
14218
- if (!link) {
14219
- showCopyrightWarning();
14220
- return false;
14221
- }
14222
- const href = link.getAttribute("href");
14223
- if (href !== "https://github.com/jitOffice/jit-viewer-sdk") {
14224
- showCopyrightWarning();
14225
- return false;
14226
- }
14227
- const text = branding.textContent || "";
14228
- if (!text.includes("JitViewer") || !text.includes("提供文档预览支持")) {
14229
- showCopyrightWarning();
14230
- return false;
14231
- }
14232
- return true;
14233
- }
14234
- function showCopyrightWarning() {
14235
- var _a;
14236
- if (document.querySelector(".jv-copyright-warning")) return;
14237
- const warning = document.createElement("div");
14238
- warning.className = "jv-copyright-warning";
14239
- warning.innerHTML = `
14240
- <div class="jv-copyright-warning__content">
14241
- <div class="jv-copyright-warning__icon">⚠️</div>
14242
- <div class="jv-copyright-warning__title">版权信息被移除</div>
14243
- <div class="jv-copyright-warning__text">
14244
- 请保留 "JitViewer提供文档预览支持" 版权信息<br>
14245
- <a href="https://github.com/jitOffice/jit-viewer-sdk" target="_blank">https://github.com/jitOffice/jit-viewer-sdk</a>
14246
- </div>
14247
- <button class="jv-copyright-warning__btn">我知道了</button>
14248
- </div>
14249
- `;
14250
- const style = document.createElement("style");
14251
- style.textContent = `
14252
- .jv-copyright-warning {
14253
- position: fixed;
14254
- top: 0;
14255
- left: 0;
14256
- right: 0;
14257
- bottom: 0;
14258
- background: rgba(0, 0, 0, 0.7);
14259
- display: flex;
14260
- align-items: center;
14261
- justify-content: center;
14262
- z-index: 99999;
14263
- }
14264
- .jv-copyright-warning__content {
14265
- background: white;
14266
- padding: 32px;
14267
- border-radius: 12px;
14268
- text-align: center;
14269
- max-width: 400px;
14270
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
14271
- }
14272
- .jv-copyright-warning__icon {
14273
- font-size: 48px;
14274
- margin-bottom: 16px;
14275
- }
14276
- .jv-copyright-warning__title {
14277
- font-size: 18px;
14278
- font-weight: 600;
14279
- margin-bottom: 12px;
14280
- color: #333;
14281
- }
14282
- .jv-copyright-warning__text {
14283
- font-size: 14px;
14284
- color: #666;
14285
- margin-bottom: 20px;
14286
- line-height: 1.6;
14287
- }
14288
- .jv-copyright-warning__text a {
14289
- color: #1890ff;
14290
- }
14291
- .jv-copyright-warning__btn {
14292
- background: #1890ff;
14293
- color: white;
14294
- border: none;
14295
- padding: 10px 32px;
14296
- border-radius: 6px;
14297
- font-size: 14px;
14298
- cursor: pointer;
14299
- }
14300
- .jv-copyright-warning__btn:hover {
14301
- background: #40a9ff;
14302
- }
14303
- `;
14304
- document.head.appendChild(style);
14305
- document.body.appendChild(warning);
14306
- (_a = warning.querySelector(".jv-copyright-warning__btn")) == null ? void 0 : _a.addEventListener("click", () => {
14307
- location.reload();
14308
- });
14309
- }
14310
- function startCopyrightProtection() {
14311
- copyrightObserver = new MutationObserver(() => {
14312
- checkCopyright();
14313
- });
14314
- if (brandingRef.value) {
14315
- const viewer = brandingRef.value.closest(".jv-viewer");
14316
- if (viewer) {
14317
- viewerRoot = viewer;
14318
- copyrightObserver.observe(viewerRoot, {
14319
- childList: true,
14320
- subtree: true,
14321
- attributes: true,
14322
- attributeFilter: ["href", "style", "class"]
14323
- });
14324
- }
14325
- }
14326
- copyrightCheckInterval = setInterval(checkCopyright, 1e3);
14327
- }
14328
- function stopCopyrightProtection() {
14329
- if (copyrightObserver) {
14330
- copyrightObserver.disconnect();
14331
- copyrightObserver = null;
14332
- }
14333
- if (copyrightCheckInterval) {
14334
- clearInterval(copyrightCheckInterval);
14335
- copyrightCheckInterval = null;
14336
- }
14337
- viewerRoot = null;
14338
- }
14339
14221
  const defaultItems = [
14340
14222
  "zoom",
14341
14223
  "rotate",
@@ -14380,32 +14262,24 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
14380
14262
  await downloadFile(fileSource.value, filename.value);
14381
14263
  }
14382
14264
  }
14383
- onMounted(() => {
14384
- setTimeout(() => {
14385
- startCopyrightProtection();
14386
- }, 100);
14387
- });
14388
- onUnmounted(() => {
14389
- stopCopyrightProtection();
14390
- });
14391
14265
  return (_ctx, _cache) => {
14392
14266
  return openBlock(), createElementBlock("div", {
14393
14267
  class: normalizeClass(["jv-toolbar", [positionClass.value, { "jv-toolbar--hidden": !__props.visible }]])
14394
14268
  }, [
14395
- showTop.value ? (openBlock(), createElementBlock("div", _hoisted_1$6, [
14396
- createBaseVNode("div", _hoisted_2$3, [
14269
+ showTop.value ? (openBlock(), createElementBlock("div", _hoisted_1$7, [
14270
+ createBaseVNode("div", _hoisted_2$4, [
14397
14271
  renderSlot(_ctx.$slots, "top-left", {}, () => [
14398
- unref(filename) ? (openBlock(), createElementBlock("span", _hoisted_3$1, toDisplayString(unref(filename)), 1)) : createCommentVNode("", true)
14272
+ unref(filename) ? (openBlock(), createElementBlock("span", _hoisted_3$2, toDisplayString(unref(filename)), 1)) : createCommentVNode("", true)
14399
14273
  ], true)
14400
14274
  ]),
14401
- createBaseVNode("div", _hoisted_4$1, [
14275
+ createBaseVNode("div", _hoisted_4$2, [
14402
14276
  renderSlot(_ctx.$slots, "top-center", {}, void 0, true)
14403
14277
  ]),
14404
14278
  createBaseVNode("div", _hoisted_5$1, [
14405
14279
  renderSlot(_ctx.$slots, "top-right", {}, () => [
14406
14280
  hasItem("zoom") ? (openBlock(), createBlock(ZoomControl, { key: 0 })) : createCommentVNode("", true),
14407
14281
  hasItem("rotate") ? (openBlock(), createBlock(RotateControl, { key: 1 })) : createCommentVNode("", true),
14408
- hasItem("fullscreen") ? (openBlock(), createBlock(_sfc_main$b, { key: 2 })) : createCommentVNode("", true)
14282
+ hasItem("fullscreen") ? (openBlock(), createBlock(_sfc_main$c, { key: 2 })) : createCommentVNode("", true)
14409
14283
  ], true)
14410
14284
  ])
14411
14285
  ])) : createCommentVNode("", true),
@@ -14420,27 +14294,13 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
14420
14294
  ]),
14421
14295
  createBaseVNode("div", _hoisted_9, [
14422
14296
  renderSlot(_ctx.$slots, "bottom-right", {}, () => [
14423
- createBaseVNode("span", {
14424
- class: "jv-toolbar__branding",
14425
- ref_key: "brandingRef",
14426
- ref: brandingRef,
14427
- "data-jv-copyright": "true"
14428
- }, [..._cache[0] || (_cache[0] = [
14429
- createBaseVNode("a", {
14430
- href: "https://github.com/jitOffice/jit-viewer-sdk",
14431
- target: "_blank",
14432
- rel: "noopener noreferrer",
14433
- class: "jv-branding-link"
14434
- }, "JitViewer", -1),
14435
- createTextVNode("提供文档预览支持 ", -1)
14436
- ])], 512),
14437
14297
  hasItem("download") ? (openBlock(), createBlock(ActionButton, {
14438
14298
  key: 0,
14439
14299
  type: "download",
14440
14300
  title: unref(t)("toolbar.download"),
14441
14301
  onClick: handleDownload
14442
14302
  }, {
14443
- default: withCtx(() => [..._cache[1] || (_cache[1] = [
14303
+ default: withCtx(() => [..._cache[0] || (_cache[0] = [
14444
14304
  createBaseVNode("svg", {
14445
14305
  viewBox: "0 0 24 24",
14446
14306
  fill: "none",
@@ -14466,7 +14326,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
14466
14326
  };
14467
14327
  }
14468
14328
  });
14469
- const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-e0907d02"]]);
14329
+ const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-74d3b30f"]]);
14470
14330
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
14471
14331
  function getDefaultExportFromCjs(x) {
14472
14332
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -19592,7 +19452,7 @@ section.${e}>footer { z-index: 1; }
19592
19452
  })(lib$4);
19593
19453
  var libExports$3 = lib$4.exports;
19594
19454
  const VueOfficeDocx = /* @__PURE__ */ getDefaultExportFromCjs(libExports$3);
19595
- const _sfc_main$8 = /* @__PURE__ */ defineComponent({
19455
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
19596
19456
  __name: "DocxRender",
19597
19457
  props: {
19598
19458
  source: {},
@@ -19647,7 +19507,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
19647
19507
  };
19648
19508
  }
19649
19509
  });
19650
- const DocxRender = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-9181c8b1"]]);
19510
+ const DocxRender = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-9181c8b1"]]);
19651
19511
  var lib$2 = { exports: {} };
19652
19512
  (function(module, exports$1) {
19653
19513
  !function(e, t) {
@@ -62434,7 +62294,7 @@ var lib$2 = { exports: {} };
62434
62294
  })(lib$2);
62435
62295
  var libExports$2 = lib$2.exports;
62436
62296
  const VueOfficeExcel = /* @__PURE__ */ getDefaultExportFromCjs(libExports$2);
62437
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
62297
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
62438
62298
  __name: "ExcelRender",
62439
62299
  props: {
62440
62300
  source: {},
@@ -62489,7 +62349,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
62489
62349
  };
62490
62350
  }
62491
62351
  });
62492
- const ExcelRender = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-a8c7c89f"]]);
62352
+ const ExcelRender = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-a8c7c89f"]]);
62493
62353
  var lib$1 = { exports: {} };
62494
62354
  (function(module, exports$1) {
62495
62355
  (function(Q, k) {
@@ -64192,8 +64052,8 @@ var t={4186:(t,e,r)=>{var n=r(3749),i=r(8055),a=TypeError;t.exports=function(t){
64192
64052
  })(lib$1);
64193
64053
  var libExports$1 = lib$1.exports;
64194
64054
  const VueOfficePdf = /* @__PURE__ */ getDefaultExportFromCjs(libExports$1);
64195
- const _hoisted_1$5 = ["src"];
64196
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
64055
+ const _hoisted_1$6 = ["src"];
64056
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
64197
64057
  __name: "PdfRender",
64198
64058
  props: {
64199
64059
  source: {},
@@ -64292,12 +64152,12 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
64292
64152
  style: normalizeStyle(renderStyle.value),
64293
64153
  frameborder: "0",
64294
64154
  onLoad: handleRendered
64295
- }, null, 44, _hoisted_1$5))
64155
+ }, null, 44, _hoisted_1$6))
64296
64156
  ], 512);
64297
64157
  };
64298
64158
  }
64299
64159
  });
64300
- const PdfRender = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-32fed398"]]);
64160
+ const PdfRender = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-32fed398"]]);
64301
64161
  var lib = { exports: {} };
64302
64162
  (function(module, exports$1) {
64303
64163
  (function(Ma, No) {
@@ -102666,7 +102526,7 @@ echarts.use([` + E + "]);" : "Unknown series " + P));
102666
102526
  })(lib);
102667
102527
  var libExports = lib.exports;
102668
102528
  const VueOfficePptx = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
102669
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
102529
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
102670
102530
  __name: "PptxRender",
102671
102531
  props: {
102672
102532
  source: {},
@@ -102721,9 +102581,9 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
102721
102581
  };
102722
102582
  }
102723
102583
  });
102724
- const PptxRender = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-b31abca4"]]);
102725
- const _hoisted_1$4 = { class: "jv-text-content" };
102726
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
102584
+ const PptxRender = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-b31abca4"]]);
102585
+ const _hoisted_1$5 = { class: "jv-text-content" };
102586
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
102727
102587
  __name: "TextRender",
102728
102588
  props: {
102729
102589
  source: {}
@@ -102755,14 +102615,14 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
102755
102615
  ref: containerRef,
102756
102616
  class: "jv-file-render jv-file-render--text"
102757
102617
  }, [
102758
- createBaseVNode("pre", _hoisted_1$4, toDisplayString(content.value), 1)
102618
+ createBaseVNode("pre", _hoisted_1$5, toDisplayString(content.value), 1)
102759
102619
  ], 512);
102760
102620
  };
102761
102621
  }
102762
102622
  });
102763
- const TextRender = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-f5957104"]]);
102764
- const _hoisted_1$3 = ["innerHTML"];
102765
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
102623
+ const TextRender = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-f5957104"]]);
102624
+ const _hoisted_1$4 = ["innerHTML"];
102625
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
102766
102626
  __name: "MarkdownRender",
102767
102627
  props: {
102768
102628
  source: {}
@@ -102779,7 +102639,89 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
102779
102639
  });
102780
102640
  function simpleMarkdownToHtml(md) {
102781
102641
  if (!md) return "";
102782
- return md.replace(/```(\w+)?\n([\s\S]*?)```/g, "<pre><code>$2</code></pre>").replace(/`([^`]+)`/g, "<code>$1</code>").replace(/^### (.*$)/gim, "<h3>$1</h3>").replace(/^## (.*$)/gim, "<h2>$1</h2>").replace(/^# (.*$)/gim, "<h1>$1</h1>").replace(/\*\*\*(.*?)\*\*\*/g, "<strong><em>$1</em></strong>").replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>").replace(/\*(.*?)\*/g, "<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank">$1</a>').replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '<img alt="$1" src="$2" />').replace(/^\s*[-*+]\s+(.*$)/gim, "<li>$1</li>").replace(/^\s*\d+\.\s+(.*$)/gim, "<li>$1</li>").replace(/^>\s+(.*$)/gim, "<blockquote>$1</blockquote>").replace(/^---$/gim, "<hr />").replace(/\n\n/g, "</p><p>").replace(/\n/g, "<br />").replace(/^(.+)$/gim, "<p>$1</p>").replace(/<p><\/p>/g, "").replace(/(<li>.*<\/li>)/s, "<ul>$1</ul>");
102642
+ let html = md.replace(/```(\w+)?\n([\s\S]*?)```/g, "<pre><code>$2</code></pre>").replace(/`([^`]+)`/g, "<code>$1</code>");
102643
+ html = parseTables(html);
102644
+ html = html.replace(/^### (.*$)/gim, "<h3>$1</h3>").replace(/^## (.*$)/gim, "<h2>$1</h2>").replace(/^# (.*$)/gim, "<h1>$1</h1>").replace(/\*\*\*(.*?)\*\*\*/g, "<strong><em>$1</em></strong>").replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>").replace(/\*(.*?)\*/g, "<em>$1</em>").replace(/___(.*?)___/g, "<strong><em>$1</em></strong>").replace(/__(.*?)__/g, "<strong>$1</strong>").replace(/_(.*?)_/g, "<em>$1</em>").replace(/~~(.*?)~~/g, "<del>$1</del>").replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2" target="_blank">$1</a>').replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '<img alt="$1" src="$2" />').replace(/^>\s+(.*$)/gim, "<blockquote>$1</blockquote>").replace(/^---$/gim, "<hr />").replace(/^\*\*\*$/gim, "<hr />").replace(/^___$/gim, "<hr />");
102645
+ html = parseLists(html);
102646
+ html = html.replace(/\n\n/g, "</p><p>").replace(/\n/g, "<br />").replace(/^(.+)$/gim, "<p>$1</p>").replace(/<p><\/p>/g, "").replace(/<p>(<[uo]l>)/g, "$1").replace(/(<\/[uo]l>)<\/p>/g, "$1").replace(/<p>(<[hb]r)/g, "$1").replace(/(<\/blockquote>)<\/p>/g, "$1");
102647
+ return html;
102648
+ }
102649
+ function parseTables(md) {
102650
+ const lines = md.split("\n");
102651
+ const result = [];
102652
+ let i = 0;
102653
+ while (i < lines.length) {
102654
+ const line = lines[i];
102655
+ if (line.includes("|")) {
102656
+ const nextLine = lines[i + 1];
102657
+ if (nextLine && /^\|?[\s|:|-]+\|/.test(nextLine)) {
102658
+ const headerLine = line;
102659
+ i += 2;
102660
+ const headers = headerLine.split("|").map((cell) => cell.trim()).filter((cell) => cell !== "").map((cell) => `<th>${cell}</th>`).join("");
102661
+ const rows = [];
102662
+ while (i < lines.length && lines[i].includes("|")) {
102663
+ const rowCells = lines[i].split("|").map((cell) => cell.trim()).filter((cell) => cell !== "").map((cell) => `<td>${cell}</td>`).join("");
102664
+ if (rowCells) {
102665
+ rows.push(`<tr>${rowCells}</tr>`);
102666
+ }
102667
+ i++;
102668
+ }
102669
+ const tableHtml = `<table><thead><tr>${headers}</tr></thead><tbody>${rows.join("")}</tbody></table>`;
102670
+ result.push(tableHtml);
102671
+ continue;
102672
+ }
102673
+ }
102674
+ result.push(line);
102675
+ i++;
102676
+ }
102677
+ return result.join("\n");
102678
+ }
102679
+ function parseLists(md) {
102680
+ const lines = md.split("\n");
102681
+ const result = [];
102682
+ let inUl = false;
102683
+ let inOl = false;
102684
+ for (let i = 0; i < lines.length; i++) {
102685
+ const line = lines[i];
102686
+ const ulMatch = line.match(/^(\s*)[-*+]\s+(.+)$/);
102687
+ const olMatch = line.match(/^(\s*)\d+\.\s+(.+)$/);
102688
+ if (ulMatch) {
102689
+ const content2 = ulMatch[2];
102690
+ if (!inUl) {
102691
+ if (inOl) {
102692
+ result.push("</ol>");
102693
+ inOl = false;
102694
+ }
102695
+ result.push("<ul>");
102696
+ inUl = true;
102697
+ }
102698
+ result.push(`<li>${content2}</li>`);
102699
+ } else if (olMatch) {
102700
+ const content2 = olMatch[2];
102701
+ if (!inOl) {
102702
+ if (inUl) {
102703
+ result.push("</ul>");
102704
+ inUl = false;
102705
+ }
102706
+ result.push("<ol>");
102707
+ inOl = true;
102708
+ }
102709
+ result.push(`<li>${content2}</li>`);
102710
+ } else {
102711
+ if (inUl) {
102712
+ result.push("</ul>");
102713
+ inUl = false;
102714
+ }
102715
+ if (inOl) {
102716
+ result.push("</ol>");
102717
+ inOl = false;
102718
+ }
102719
+ result.push(line);
102720
+ }
102721
+ }
102722
+ if (inUl) result.push("</ul>");
102723
+ if (inOl) result.push("</ol>");
102724
+ return result.join("\n");
102783
102725
  }
102784
102726
  async function loadFile() {
102785
102727
  try {
@@ -102804,12 +102746,12 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
102804
102746
  createBaseVNode("div", {
102805
102747
  class: "jv-markdown-content",
102806
102748
  innerHTML: renderedContent.value
102807
- }, null, 8, _hoisted_1$3)
102749
+ }, null, 8, _hoisted_1$4)
102808
102750
  ], 512);
102809
102751
  };
102810
102752
  }
102811
102753
  });
102812
- const MarkdownRender = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-9b60bb2a"]]);
102754
+ const MarkdownRender = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-2d9fb509"]]);
102813
102755
  var dist = { exports: {} };
102814
102756
  /*! For license information please see index.js.LICENSE.txt */
102815
102757
  (function(module, exports$1) {
@@ -128443,12 +128385,12 @@ class LiteOfdAdapter {
128443
128385
  this.instance = null;
128444
128386
  }
128445
128387
  }
128446
- const _hoisted_1$2 = {
128388
+ const _hoisted_1$3 = {
128447
128389
  key: 0,
128448
128390
  class: "jv-ofd-error"
128449
128391
  };
128450
- const _hoisted_2$2 = { class: "jv-ofd-loading" };
128451
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
128392
+ const _hoisted_2$3 = { class: "jv-ofd-loading" };
128393
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
128452
128394
  __name: "OfdRender",
128453
128395
  props: {
128454
128396
  source: {},
@@ -128679,7 +128621,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
128679
128621
  ref: containerRef,
128680
128622
  class: "jv-file-render jv-file-render--ofd"
128681
128623
  }, [
128682
- error.value ? (openBlock(), createElementBlock("div", _hoisted_1$2, [
128624
+ error.value ? (openBlock(), createElementBlock("div", _hoisted_1$3, [
128683
128625
  createBaseVNode("span", null, toDisplayString(error.value), 1)
128684
128626
  ])) : (openBlock(), createElementBlock("div", {
128685
128627
  key: 1,
@@ -128698,7 +128640,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
128698
128640
  }, null, 512)
128699
128641
  ], 4)
128700
128642
  ], 512)),
128701
- withDirectives(createBaseVNode("div", _hoisted_2$2, [
128643
+ withDirectives(createBaseVNode("div", _hoisted_2$3, [
128702
128644
  createBaseVNode("span", null, toDisplayString(t("loading")), 1)
128703
128645
  ], 512), [
128704
128646
  [vShow, loading.value]
@@ -128707,13 +128649,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
128707
128649
  };
128708
128650
  }
128709
128651
  });
128710
- const OfdRender = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-f933a20c"]]);
128711
- const _hoisted_1$1 = { class: "jv-html-loading" };
128712
- const _hoisted_2$1 = {
128652
+ const OfdRender = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-f933a20c"]]);
128653
+ const _hoisted_1$2 = { class: "jv-html-loading" };
128654
+ const _hoisted_2$2 = {
128713
128655
  key: 0,
128714
128656
  class: "jv-html-error"
128715
128657
  };
128716
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
128658
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
128717
128659
  __name: "HtmlRender",
128718
128660
  props: {
128719
128661
  source: {},
@@ -128871,20 +128813,427 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
128871
128813
  style: normalizeStyle(renderStyle.value),
128872
128814
  sandbox: "allow-scripts allow-same-origin allow-popups allow-forms allow-top-navigation"
128873
128815
  }, null, 4),
128874
- withDirectives(createBaseVNode("div", _hoisted_1$1, [..._cache[0] || (_cache[0] = [
128816
+ withDirectives(createBaseVNode("div", _hoisted_1$2, [..._cache[0] || (_cache[0] = [
128875
128817
  createBaseVNode("div", { class: "jv-loading-spinner" }, null, -1),
128876
128818
  createBaseVNode("span", null, "加载中...", -1)
128877
128819
  ])], 512), [
128878
128820
  [vShow, loading.value]
128879
128821
  ]),
128880
- error.value ? (openBlock(), createElementBlock("div", _hoisted_2$1, [
128822
+ error.value ? (openBlock(), createElementBlock("div", _hoisted_2$2, [
128881
128823
  createBaseVNode("span", null, toDisplayString(error.value), 1)
128882
128824
  ])) : createCommentVNode("", true)
128883
128825
  ], 512);
128884
128826
  };
128885
128827
  }
128886
128828
  });
128887
- const HtmlRender = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-af6df043"]]);
128829
+ const HtmlRender = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-af6df043"]]);
128830
+ const _hoisted_1$1 = {
128831
+ key: 0,
128832
+ class: "jv-image-loading"
128833
+ };
128834
+ const _hoisted_2$1 = {
128835
+ key: 1,
128836
+ class: "jv-image-error"
128837
+ };
128838
+ const _hoisted_3$1 = ["src", "alt"];
128839
+ const _hoisted_4$1 = {
128840
+ key: 2,
128841
+ class: "jv-image-info"
128842
+ };
128843
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
128844
+ __name: "ImageRender",
128845
+ props: {
128846
+ source: {},
128847
+ zoom: { default: 1 }
128848
+ },
128849
+ emits: ["load", "error"],
128850
+ setup(__props, { emit: __emit }) {
128851
+ const props = __props;
128852
+ const emit2 = __emit;
128853
+ const containerRef = /* @__PURE__ */ ref();
128854
+ const imageWrapperRef = /* @__PURE__ */ ref();
128855
+ const imageRef = /* @__PURE__ */ ref();
128856
+ const loading = /* @__PURE__ */ ref(true);
128857
+ const error = /* @__PURE__ */ ref(null);
128858
+ const imageSrc = /* @__PURE__ */ ref("");
128859
+ const imageAlt = /* @__PURE__ */ ref("");
128860
+ const imageInfo = /* @__PURE__ */ ref(null);
128861
+ const scale = /* @__PURE__ */ ref(1);
128862
+ const rotation = /* @__PURE__ */ ref(0);
128863
+ const translateX = /* @__PURE__ */ ref(0);
128864
+ const translateY = /* @__PURE__ */ ref(0);
128865
+ const isDragging = /* @__PURE__ */ ref(false);
128866
+ const dragStart = /* @__PURE__ */ ref({ x: 0, y: 0 });
128867
+ const initialTranslate = /* @__PURE__ */ ref({ x: 0, y: 0 });
128868
+ const naturalSize = /* @__PURE__ */ ref({ width: 0, height: 0 });
128869
+ const imageStyle = computed(() => ({
128870
+ transform: `translate(${translateX.value}px, ${translateY.value}px) rotate(${rotation.value}deg) scale(${scale.value})`,
128871
+ transition: isDragging.value ? "none" : "transform 0.2s ease",
128872
+ cursor: isDragging.value ? "grabbing" : scale.value > 1 ? "grab" : "default"
128873
+ }));
128874
+ async function loadImage() {
128875
+ try {
128876
+ loading.value = true;
128877
+ error.value = null;
128878
+ const blob = await fileToBlob(props.source);
128879
+ imageInfo.value = {
128880
+ width: 0,
128881
+ height: 0,
128882
+ size: blob.size
128883
+ };
128884
+ imageSrc.value = URL.createObjectURL(blob);
128885
+ if (props.source instanceof File) {
128886
+ imageAlt.value = props.source.name;
128887
+ }
128888
+ } catch (err) {
128889
+ loading.value = false;
128890
+ error.value = err;
128891
+ emit2("error", err);
128892
+ }
128893
+ }
128894
+ function handleImageLoad() {
128895
+ if (imageRef.value) {
128896
+ naturalSize.value = {
128897
+ width: imageRef.value.naturalWidth,
128898
+ height: imageRef.value.naturalHeight
128899
+ };
128900
+ if (imageInfo.value) {
128901
+ imageInfo.value.width = imageRef.value.naturalWidth;
128902
+ imageInfo.value.height = imageRef.value.naturalHeight;
128903
+ }
128904
+ fitToScreen();
128905
+ loading.value = false;
128906
+ emit2("load");
128907
+ }
128908
+ }
128909
+ function handleImageError() {
128910
+ loading.value = false;
128911
+ error.value = new Error("图片加载失败");
128912
+ emit2("error", error.value);
128913
+ }
128914
+ function zoomIn() {
128915
+ scale.value = Math.min(scale.value * 1.25, 10);
128916
+ }
128917
+ function zoomOut() {
128918
+ scale.value = Math.max(scale.value / 1.25, 0.1);
128919
+ if (scale.value <= 1) {
128920
+ translateX.value = 0;
128921
+ translateY.value = 0;
128922
+ }
128923
+ }
128924
+ function resetZoom() {
128925
+ scale.value = 1;
128926
+ rotation.value = 0;
128927
+ translateX.value = 0;
128928
+ translateY.value = 0;
128929
+ }
128930
+ function fitToScreen() {
128931
+ if (!imageRef.value || !containerRef.value) return;
128932
+ const containerRect = containerRef.value.getBoundingClientRect();
128933
+ const containerWidth = containerRect.width - 40;
128934
+ const containerHeight = containerRect.height - 40;
128935
+ const imgWidth = naturalSize.value.width;
128936
+ const imgHeight = naturalSize.value.height;
128937
+ const scaleX = containerWidth / imgWidth;
128938
+ const scaleY = containerHeight / imgHeight;
128939
+ const fitScale = Math.min(scaleX, scaleY, 1);
128940
+ scale.value = fitScale;
128941
+ rotation.value = 0;
128942
+ translateX.value = 0;
128943
+ translateY.value = 0;
128944
+ }
128945
+ function rotateLeft() {
128946
+ rotation.value -= 90;
128947
+ }
128948
+ function rotateRight() {
128949
+ rotation.value += 90;
128950
+ }
128951
+ function handleWheel(e) {
128952
+ const delta = e.deltaY > 0 ? 0.9 : 1.1;
128953
+ const newScale = Math.min(Math.max(scale.value * delta, 0.1), 10);
128954
+ if (newScale !== scale.value && imageWrapperRef.value) {
128955
+ const rect = imageWrapperRef.value.getBoundingClientRect();
128956
+ const mouseX = e.clientX - rect.left - rect.width / 2;
128957
+ const mouseY = e.clientY - rect.top - rect.height / 2;
128958
+ const scaleRatio = newScale / scale.value;
128959
+ translateX.value = translateX.value * scaleRatio + mouseX * (scaleRatio - 1);
128960
+ translateY.value = translateY.value * scaleRatio + mouseY * (scaleRatio - 1);
128961
+ scale.value = newScale;
128962
+ if (scale.value <= 1) {
128963
+ translateX.value = 0;
128964
+ translateY.value = 0;
128965
+ }
128966
+ }
128967
+ }
128968
+ function handleDoubleClick() {
128969
+ if (scale.value !== 1) {
128970
+ resetZoom();
128971
+ } else {
128972
+ scale.value = 2;
128973
+ }
128974
+ }
128975
+ function handleMouseDown(e) {
128976
+ if (scale.value <= 1) return;
128977
+ isDragging.value = true;
128978
+ dragStart.value = { x: e.clientX, y: e.clientY };
128979
+ initialTranslate.value = { x: translateX.value, y: translateY.value };
128980
+ }
128981
+ function handleMouseMove(e) {
128982
+ if (!isDragging.value) return;
128983
+ const dx = e.clientX - dragStart.value.x;
128984
+ const dy = e.clientY - dragStart.value.y;
128985
+ translateX.value = initialTranslate.value.x + dx;
128986
+ translateY.value = initialTranslate.value.y + dy;
128987
+ }
128988
+ function handleMouseUp() {
128989
+ isDragging.value = false;
128990
+ }
128991
+ function toggleFullscreen() {
128992
+ if (!containerRef.value) return;
128993
+ if (!document.fullscreenElement) {
128994
+ containerRef.value.requestFullscreen();
128995
+ } else {
128996
+ document.exitFullscreen();
128997
+ }
128998
+ }
128999
+ async function downloadImage() {
129000
+ await downloadFile(props.source, imageAlt.value || "image");
129001
+ }
129002
+ function formatFileSize(bytes) {
129003
+ if (bytes === 0) return "0 B";
129004
+ const k = 1024;
129005
+ const sizes = ["B", "KB", "MB", "GB"];
129006
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
129007
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
129008
+ }
129009
+ watch(() => props.zoom, (newZoom) => {
129010
+ scale.value = newZoom;
129011
+ });
129012
+ watch(() => props.source, () => {
129013
+ if (imageSrc.value) {
129014
+ URL.revokeObjectURL(imageSrc.value);
129015
+ }
129016
+ resetZoom();
129017
+ loadImage();
129018
+ }, { immediate: true });
129019
+ onUnmounted(() => {
129020
+ if (imageSrc.value) {
129021
+ URL.revokeObjectURL(imageSrc.value);
129022
+ }
129023
+ });
129024
+ return (_ctx, _cache) => {
129025
+ return openBlock(), createElementBlock("div", {
129026
+ ref_key: "containerRef",
129027
+ ref: containerRef,
129028
+ class: "jv-file-render jv-file-render--image"
129029
+ }, [
129030
+ loading.value ? (openBlock(), createElementBlock("div", _hoisted_1$1, [..._cache[0] || (_cache[0] = [
129031
+ createBaseVNode("div", { class: "jv-loading-spinner" }, null, -1),
129032
+ createBaseVNode("span", null, "加载中...", -1)
129033
+ ])])) : error.value ? (openBlock(), createElementBlock("div", _hoisted_2$1, [
129034
+ _cache[1] || (_cache[1] = createBaseVNode("svg", {
129035
+ viewBox: "0 0 24 24",
129036
+ fill: "none",
129037
+ stroke: "currentColor",
129038
+ "stroke-width": "2"
129039
+ }, [
129040
+ createBaseVNode("circle", {
129041
+ cx: "12",
129042
+ cy: "12",
129043
+ r: "10"
129044
+ }),
129045
+ createBaseVNode("line", {
129046
+ x1: "12",
129047
+ y1: "8",
129048
+ x2: "12",
129049
+ y2: "12"
129050
+ }),
129051
+ createBaseVNode("line", {
129052
+ x1: "12",
129053
+ y1: "16",
129054
+ x2: "12.01",
129055
+ y2: "16"
129056
+ })
129057
+ ], -1)),
129058
+ createBaseVNode("span", null, toDisplayString(error.value.message || "图片加载失败"), 1)
129059
+ ])) : createCommentVNode("", true),
129060
+ withDirectives(createBaseVNode("div", {
129061
+ ref_key: "imageWrapperRef",
129062
+ ref: imageWrapperRef,
129063
+ class: normalizeClass(["jv-image-wrapper", { "jv-image-wrapper--dragging": isDragging.value }]),
129064
+ onWheel: withModifiers(handleWheel, ["prevent"]),
129065
+ onMousedown: withModifiers(handleMouseDown, ["prevent"]),
129066
+ onMousemove: handleMouseMove,
129067
+ onMouseup: handleMouseUp,
129068
+ onMouseleave: handleMouseUp,
129069
+ onDblclick: handleDoubleClick
129070
+ }, [
129071
+ imageSrc.value ? (openBlock(), createElementBlock("img", {
129072
+ key: 0,
129073
+ ref_key: "imageRef",
129074
+ ref: imageRef,
129075
+ src: imageSrc.value,
129076
+ alt: imageAlt.value,
129077
+ class: "jv-image",
129078
+ style: normalizeStyle(imageStyle.value),
129079
+ draggable: "false",
129080
+ onLoad: handleImageLoad,
129081
+ onError: handleImageError
129082
+ }, null, 44, _hoisted_3$1)) : createCommentVNode("", true)
129083
+ ], 34), [
129084
+ [vShow, !loading.value && !error.value]
129085
+ ]),
129086
+ createBaseVNode("div", { class: "jv-image-controls" }, [
129087
+ createBaseVNode("button", {
129088
+ class: "jv-image-btn",
129089
+ title: "放大",
129090
+ onClick: zoomIn
129091
+ }, [..._cache[2] || (_cache[2] = [
129092
+ createStaticVNode('<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" data-v-cc028f53><circle cx="11" cy="11" r="8" data-v-cc028f53></circle><line x1="21" y1="21" x2="16.65" y2="16.65" data-v-cc028f53></line><line x1="11" y1="8" x2="11" y2="14" data-v-cc028f53></line><line x1="8" y1="11" x2="14" y2="11" data-v-cc028f53></line></svg>', 1)
129093
+ ])]),
129094
+ createBaseVNode("button", {
129095
+ class: "jv-image-btn",
129096
+ title: "缩小",
129097
+ onClick: zoomOut
129098
+ }, [..._cache[3] || (_cache[3] = [
129099
+ createBaseVNode("svg", {
129100
+ viewBox: "0 0 24 24",
129101
+ fill: "none",
129102
+ stroke: "currentColor",
129103
+ "stroke-width": "2"
129104
+ }, [
129105
+ createBaseVNode("circle", {
129106
+ cx: "11",
129107
+ cy: "11",
129108
+ r: "8"
129109
+ }),
129110
+ createBaseVNode("line", {
129111
+ x1: "21",
129112
+ y1: "21",
129113
+ x2: "16.65",
129114
+ y2: "16.65"
129115
+ }),
129116
+ createBaseVNode("line", {
129117
+ x1: "8",
129118
+ y1: "11",
129119
+ x2: "14",
129120
+ y2: "11"
129121
+ })
129122
+ ], -1)
129123
+ ])]),
129124
+ createBaseVNode("button", {
129125
+ class: "jv-image-btn",
129126
+ title: "适应屏幕",
129127
+ onClick: fitToScreen
129128
+ }, [..._cache[4] || (_cache[4] = [
129129
+ createBaseVNode("svg", {
129130
+ viewBox: "0 0 24 24",
129131
+ fill: "none",
129132
+ stroke: "currentColor",
129133
+ "stroke-width": "2"
129134
+ }, [
129135
+ createBaseVNode("path", { d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" })
129136
+ ], -1)
129137
+ ])]),
129138
+ createBaseVNode("button", {
129139
+ class: "jv-image-btn",
129140
+ title: "实际大小",
129141
+ onClick: resetZoom
129142
+ }, [..._cache[5] || (_cache[5] = [
129143
+ createBaseVNode("svg", {
129144
+ viewBox: "0 0 24 24",
129145
+ fill: "none",
129146
+ stroke: "currentColor",
129147
+ "stroke-width": "2"
129148
+ }, [
129149
+ createBaseVNode("rect", {
129150
+ x: "3",
129151
+ y: "3",
129152
+ width: "18",
129153
+ height: "18",
129154
+ rx: "2",
129155
+ ry: "2"
129156
+ }),
129157
+ createBaseVNode("line", {
129158
+ x1: "9",
129159
+ y1: "3",
129160
+ x2: "9",
129161
+ y2: "21"
129162
+ })
129163
+ ], -1)
129164
+ ])]),
129165
+ createBaseVNode("button", {
129166
+ class: "jv-image-btn",
129167
+ title: "向左旋转",
129168
+ onClick: rotateLeft
129169
+ }, [..._cache[6] || (_cache[6] = [
129170
+ createBaseVNode("svg", {
129171
+ viewBox: "0 0 24 24",
129172
+ fill: "none",
129173
+ stroke: "currentColor",
129174
+ "stroke-width": "2"
129175
+ }, [
129176
+ createBaseVNode("polyline", { points: "9 14 4 9 9 4" }),
129177
+ createBaseVNode("path", { d: "M4 9h10a5 5 0 0 1 5 5v0" })
129178
+ ], -1)
129179
+ ])]),
129180
+ createBaseVNode("button", {
129181
+ class: "jv-image-btn",
129182
+ title: "向右旋转",
129183
+ onClick: rotateRight
129184
+ }, [..._cache[7] || (_cache[7] = [
129185
+ createBaseVNode("svg", {
129186
+ viewBox: "0 0 24 24",
129187
+ fill: "none",
129188
+ stroke: "currentColor",
129189
+ "stroke-width": "2"
129190
+ }, [
129191
+ createBaseVNode("polyline", { points: "15 14 20 9 15 4" }),
129192
+ createBaseVNode("path", { d: "M20 9H10a5 5 0 0 0-5 5v0" })
129193
+ ], -1)
129194
+ ])]),
129195
+ createBaseVNode("button", {
129196
+ class: "jv-image-btn",
129197
+ title: "全屏查看",
129198
+ onClick: toggleFullscreen
129199
+ }, [..._cache[8] || (_cache[8] = [
129200
+ createBaseVNode("svg", {
129201
+ viewBox: "0 0 24 24",
129202
+ fill: "none",
129203
+ stroke: "currentColor",
129204
+ "stroke-width": "2"
129205
+ }, [
129206
+ createBaseVNode("path", { d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" })
129207
+ ], -1)
129208
+ ])]),
129209
+ createBaseVNode("button", {
129210
+ class: "jv-image-btn",
129211
+ title: "下载图片",
129212
+ onClick: downloadImage
129213
+ }, [..._cache[9] || (_cache[9] = [
129214
+ createBaseVNode("svg", {
129215
+ viewBox: "0 0 24 24",
129216
+ fill: "none",
129217
+ stroke: "currentColor",
129218
+ "stroke-width": "2"
129219
+ }, [
129220
+ createBaseVNode("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
129221
+ createBaseVNode("polyline", { points: "7 10 12 15 17 10" }),
129222
+ createBaseVNode("line", {
129223
+ x1: "12",
129224
+ y1: "15",
129225
+ x2: "12",
129226
+ y2: "3"
129227
+ })
129228
+ ], -1)
129229
+ ])])
129230
+ ]),
129231
+ imageInfo.value ? (openBlock(), createElementBlock("div", _hoisted_4$1, toDisplayString(imageInfo.value.width) + " × " + toDisplayString(imageInfo.value.height) + " | " + toDisplayString(formatFileSize(imageInfo.value.size)), 1)) : createCommentVNode("", true)
129232
+ ], 512);
129233
+ };
129234
+ }
129235
+ });
129236
+ const ImageRender = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-cc028f53"]]);
128888
129237
  const _hoisted_1 = {
128889
129238
  key: 0,
128890
129239
  class: "jv-viewer__error"
@@ -128898,11 +129247,11 @@ const _hoisted_4 = { class: "jv-empty-text" };
128898
129247
  const _hoisted_5 = { class: "jv-viewer__loading-overlay" };
128899
129248
  const _hoisted_6 = { class: "jv-loading-text" };
128900
129249
  const _hoisted_7 = {
128901
- key: 8,
129250
+ key: 9,
128902
129251
  class: "jv-viewer__unsupported"
128903
129252
  };
128904
129253
  const _hoisted_8 = {
128905
- key: 9,
129254
+ key: 10,
128906
129255
  class: "jv-viewer__unsupported"
128907
129256
  };
128908
129257
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -128937,6 +129286,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
128937
129286
  const viewerRef = /* @__PURE__ */ ref();
128938
129287
  const contentRef = /* @__PURE__ */ ref();
128939
129288
  const ofdRenderRef = /* @__PURE__ */ ref(null);
129289
+ const brandingRef = /* @__PURE__ */ ref();
129290
+ let viewerRoot = null;
129291
+ let copyrightObserver = null;
129292
+ let copyrightCheckInterval = null;
128940
129293
  const events = createEventBus();
128941
129294
  const { t } = useLocaleProvider(props.locale);
128942
129295
  const viewerRefForTheme = computed(() => viewerRef.value || null);
@@ -129027,6 +129380,141 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
129027
129380
  }
129028
129381
  });
129029
129382
  }
129383
+ function checkCopyright() {
129384
+ const branding = brandingRef.value;
129385
+ if (!branding) return false;
129386
+ if (!viewerRoot) {
129387
+ viewerRoot = branding.closest(".jv-viewer");
129388
+ }
129389
+ if (!viewerRoot || !document.body.contains(viewerRoot)) {
129390
+ return false;
129391
+ }
129392
+ if (!viewerRoot.contains(branding)) {
129393
+ showCopyrightWarning();
129394
+ return false;
129395
+ }
129396
+ const link = branding.querySelector(".jv-branding-link");
129397
+ if (!link) {
129398
+ showCopyrightWarning();
129399
+ return false;
129400
+ }
129401
+ const href = link.getAttribute("href");
129402
+ if (href !== "https://github.com/jitOffice/jit-viewer-sdk") {
129403
+ showCopyrightWarning();
129404
+ return false;
129405
+ }
129406
+ const text = branding.textContent || "";
129407
+ if (!text.includes("JitViewer") || !text.includes("提供文档预览支持")) {
129408
+ showCopyrightWarning();
129409
+ return false;
129410
+ }
129411
+ return true;
129412
+ }
129413
+ function showCopyrightWarning() {
129414
+ var _a2;
129415
+ if (document.querySelector(".jv-copyright-warning")) return;
129416
+ const warning = document.createElement("div");
129417
+ warning.className = "jv-copyright-warning";
129418
+ warning.innerHTML = `
129419
+ <div class="jv-copyright-warning__content">
129420
+ <div class="jv-copyright-warning__icon">⚠️</div>
129421
+ <div class="jv-copyright-warning__title">版权信息被移除</div>
129422
+ <div class="jv-copyright-warning__text">
129423
+ 请保留 "JitViewer提供文档预览支持" 版权信息<br>
129424
+ <a href="https://github.com/jitOffice/jit-viewer-sdk" target="_blank">https://github.com/jitOffice/jit-viewer-sdk</a>
129425
+ </div>
129426
+ <button class="jv-copyright-warning__btn">我知道了</button>
129427
+ </div>
129428
+ `;
129429
+ const style = document.createElement("style");
129430
+ style.textContent = `
129431
+ .jv-copyright-warning {
129432
+ position: fixed;
129433
+ top: 0;
129434
+ left: 0;
129435
+ right: 0;
129436
+ bottom: 0;
129437
+ background: rgba(0, 0, 0, 0.7);
129438
+ display: flex;
129439
+ align-items: center;
129440
+ justify-content: center;
129441
+ z-index: 99999;
129442
+ }
129443
+ .jv-copyright-warning__content {
129444
+ background: white;
129445
+ padding: 32px;
129446
+ border-radius: 12px;
129447
+ text-align: center;
129448
+ max-width: 400px;
129449
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
129450
+ }
129451
+ .jv-copyright-warning__icon {
129452
+ font-size: 48px;
129453
+ margin-bottom: 16px;
129454
+ }
129455
+ .jv-copyright-warning__title {
129456
+ font-size: 18px;
129457
+ font-weight: 600;
129458
+ margin-bottom: 12px;
129459
+ color: #333;
129460
+ }
129461
+ .jv-copyright-warning__text {
129462
+ font-size: 14px;
129463
+ color: #666;
129464
+ margin-bottom: 20px;
129465
+ line-height: 1.6;
129466
+ }
129467
+ .jv-copyright-warning__text a {
129468
+ color: #1890ff;
129469
+ }
129470
+ .jv-copyright-warning__btn {
129471
+ background: #1890ff;
129472
+ color: white;
129473
+ border: none;
129474
+ padding: 10px 32px;
129475
+ border-radius: 6px;
129476
+ font-size: 14px;
129477
+ cursor: pointer;
129478
+ }
129479
+ .jv-copyright-warning__btn:hover {
129480
+ background: #40a9ff;
129481
+ }
129482
+ `;
129483
+ document.head.appendChild(style);
129484
+ document.body.appendChild(warning);
129485
+ (_a2 = warning.querySelector(".jv-copyright-warning__btn")) == null ? void 0 : _a2.addEventListener("click", () => {
129486
+ location.reload();
129487
+ });
129488
+ }
129489
+ function startCopyrightProtection() {
129490
+ copyrightObserver = new MutationObserver(() => {
129491
+ checkCopyright();
129492
+ });
129493
+ if (brandingRef.value) {
129494
+ const viewer = brandingRef.value.closest(".jv-viewer");
129495
+ if (viewer) {
129496
+ viewerRoot = viewer;
129497
+ copyrightObserver.observe(viewerRoot, {
129498
+ childList: true,
129499
+ subtree: true,
129500
+ attributes: true,
129501
+ attributeFilter: ["href", "style", "class"]
129502
+ });
129503
+ }
129504
+ }
129505
+ copyrightCheckInterval = setInterval(checkCopyright, 1e3);
129506
+ }
129507
+ function stopCopyrightProtection() {
129508
+ if (copyrightObserver) {
129509
+ copyrightObserver.disconnect();
129510
+ copyrightObserver = null;
129511
+ }
129512
+ if (copyrightCheckInterval) {
129513
+ clearInterval(copyrightCheckInterval);
129514
+ copyrightCheckInterval = null;
129515
+ }
129516
+ viewerRoot = null;
129517
+ }
129030
129518
  async function mount(target) {
129031
129519
  var _a2;
129032
129520
  const el = target ? getElement(target) : viewerRef.value;
@@ -129076,11 +129564,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
129076
129564
  if (props.file) {
129077
129565
  setFileInternal(props.file, props.filename);
129078
129566
  }
129567
+ startCopyrightProtection();
129079
129568
  emit2("ready");
129080
129569
  events.emit("ready");
129081
129570
  (_a2 = props.onReady) == null ? void 0 : _a2.call(props);
129082
129571
  });
129083
129572
  onUnmounted(() => {
129573
+ stopCopyrightProtection();
129084
129574
  state.setPageController(null);
129085
129575
  destroy();
129086
129576
  });
@@ -129141,13 +129631,26 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
129141
129631
  config: toolbarConfig.value,
129142
129632
  visible: toolbarVisible.value
129143
129633
  }, null, 8, ["config", "visible"])) : createCommentVNode("", true),
129634
+ createBaseVNode("div", {
129635
+ class: "jv-viewer__branding",
129636
+ ref_key: "brandingRef",
129637
+ ref: brandingRef
129638
+ }, [..._cache[0] || (_cache[0] = [
129639
+ createBaseVNode("a", {
129640
+ href: "https://github.com/jitOffice/jit-viewer-sdk",
129641
+ target: "_blank",
129642
+ rel: "noopener noreferrer",
129643
+ class: "jv-branding-link"
129644
+ }, "JitViewer", -1),
129645
+ createTextVNode("提供文档预览支持 ", -1)
129646
+ ])], 512),
129144
129647
  createBaseVNode("div", {
129145
129648
  ref_key: "contentRef",
129146
129649
  ref: contentRef,
129147
129650
  class: "jv-viewer__content"
129148
129651
  }, [
129149
129652
  unref(error) ? (openBlock(), createElementBlock("div", _hoisted_1, [
129150
- _cache[0] || (_cache[0] = createBaseVNode("svg", {
129653
+ _cache[1] || (_cache[1] = createBaseVNode("svg", {
129151
129654
  class: "jv-error-icon",
129152
129655
  viewBox: "0 0 24 24",
129153
129656
  fill: "none",
@@ -129181,7 +129684,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
129181
129684
  style: normalizeStyle(renderStyle.value)
129182
129685
  }, [
129183
129686
  withDirectives(createBaseVNode("div", _hoisted_5, [
129184
- _cache[1] || (_cache[1] = createBaseVNode("div", { class: "jv-loading-spinner" }, null, -1)),
129687
+ _cache[2] || (_cache[2] = createBaseVNode("div", { class: "jv-loading-spinner" }, null, -1)),
129185
129688
  createBaseVNode("span", _hoisted_6, toDisplayString(unref(t)("loading")), 1)
129186
129689
  ], 512), [
129187
129690
  [vShow, unref(loading)]
@@ -129248,7 +129751,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
129248
129751
  "request-adapter": requestAdapter.value,
129249
129752
  onLoad: handleLoad,
129250
129753
  onError: handleError2
129251
- }, null, 8, ["source", "zoom", "proxy-url", "request-adapter"])) : unref(fileType) === "unknown" && unref(fileSource) ? (openBlock(), createElementBlock("div", _hoisted_7, [..._cache[2] || (_cache[2] = [
129754
+ }, null, 8, ["source", "zoom", "proxy-url", "request-adapter"])) : unref(fileType) === "image" ? (openBlock(), createBlock(unref(ImageRender), {
129755
+ key: 8,
129756
+ source: unref(fileSource),
129757
+ zoom: unref(zoom),
129758
+ onLoad: handleLoad,
129759
+ onError: handleError2
129760
+ }, null, 8, ["source", "zoom"])) : unref(fileType) === "unknown" && unref(fileSource) ? (openBlock(), createElementBlock("div", _hoisted_7, [..._cache[3] || (_cache[3] = [
129252
129761
  createBaseVNode("span", null, "未知文件类型", -1)
129253
129762
  ])])) : (openBlock(), createElementBlock("div", _hoisted_8, [
129254
129763
  createBaseVNode("span", null, toDisplayString(unref(t)("error.unsupportedType")), 1)
@@ -129259,7 +129768,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
129259
129768
  };
129260
129769
  }
129261
129770
  });
129262
- const Viewer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-67f01523"]]);
129771
+ const Viewer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-12fe006b"]]);
129263
129772
  function createViewer(options) {
129264
129773
  const events = createEventBus();
129265
129774
  let app = null;
@@ -129411,6 +129920,7 @@ export {
129411
129920
  DocxRender,
129412
129921
  ExcelRender,
129413
129922
  HtmlRender,
129923
+ ImageRender,
129414
129924
  MarkdownRender,
129415
129925
  OfdRender,
129416
129926
  PdfRender,