@veltra/desktop 1.0.10 → 1.0.11

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.
Files changed (49) hide show
  1. package/dist/components/action/action-group.vue.d.ts +1 -1
  2. package/dist/components/action/action.vue.d.ts +3 -3
  3. package/dist/components/auto-complete/auto-complete.vue.d.ts +1 -1
  4. package/dist/components/batch-edit/batch-edit.vue.d.ts +2 -2
  5. package/dist/components/button/button.vue.d.ts +1 -1
  6. package/dist/components/cascade/cascade.vue.d.ts +6 -6
  7. package/dist/components/checkbox-group/checkbox-group.vue.d.ts +2 -2
  8. package/dist/components/code-editor/code-editor.js +2 -0
  9. package/dist/components/code-editor/code-editor.js.map +1 -1
  10. package/dist/components/date-panel/date-panel.vue.d.ts +1 -1
  11. package/dist/components/date-picker/date-picker.vue.d.ts +1 -1
  12. package/dist/components/date-range-picker/date-range-picker.vue.d.ts +1 -1
  13. package/dist/components/file-picker/file-picker.vue.d.ts +1 -1
  14. package/dist/components/file-viewer/file-viewer.js +195 -30
  15. package/dist/components/file-viewer/file-viewer.js.map +1 -1
  16. package/dist/components/file-viewer/previewers/docx-previewer.js +7 -5
  17. package/dist/components/file-viewer/previewers/docx-previewer.js.map +1 -1
  18. package/dist/components/file-viewer/previewers/image-previewer.js +6 -6
  19. package/dist/components/file-viewer/previewers/image-previewer.js.map +1 -1
  20. package/dist/components/file-viewer/previewers/pdf-previewer.js +5 -3
  21. package/dist/components/file-viewer/previewers/pdf-previewer.js.map +1 -1
  22. package/dist/components/file-viewer/style2.css +387 -136
  23. package/dist/components/grid-input/grid-input.vue.d.ts +1 -1
  24. package/dist/components/input/input.vue.d.ts +3 -3
  25. package/dist/components/multi-select/multi-select.vue.d.ts +4 -4
  26. package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +7 -7
  27. package/dist/components/notification/notification.vue.d.ts +1 -1
  28. package/dist/components/number-input/number-input.vue.d.ts +1 -1
  29. package/dist/components/number-range-input/number-range-input.vue.d.ts +1 -1
  30. package/dist/components/password-input/password-input.vue.d.ts +1 -1
  31. package/dist/components/pop-confirm/pop-confirm.vue.d.ts +2 -2
  32. package/dist/components/radio-group/radio-group.vue.d.ts +2 -2
  33. package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +1 -1
  34. package/dist/components/select/select.vue.d.ts +3 -3
  35. package/dist/components/table/table.vue.d.ts +2 -2
  36. package/dist/components/tabs/tabs-horizontal.vue.d.ts +2 -2
  37. package/dist/components/tabs/tabs-vertical.vue.d.ts +2 -2
  38. package/dist/components/tabs/tabs.vue.d.ts +2 -2
  39. package/dist/components/textarea/textarea.vue.d.ts +4 -4
  40. package/dist/components/tip/tip.vue.d.ts +2 -2
  41. package/dist/components/tree/tree.vue.d.ts +6 -6
  42. package/dist/components/tree-select/tree-select.vue.d.ts +7 -7
  43. package/package.json +13 -12
  44. package/src/components/code-editor/code-editor.vue +2 -0
  45. package/src/components/file-viewer/file-viewer.vue +250 -24
  46. package/src/components/file-viewer/previewers/docx-previewer.vue +4 -3
  47. package/src/components/file-viewer/previewers/image-previewer.vue +4 -5
  48. package/src/components/file-viewer/previewers/pdf-previewer.vue +4 -3
  49. package/src/components/file-viewer/style.scss +503 -161
@@ -1,9 +1,10 @@
1
1
  import _sfc_main$1 from "../../scroll/scroll.js";
2
- import { createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, normalizeClass, onBeforeUnmount, openBlock, ref, unref, useTemplateRef, watch, withCtx } from "vue";
2
+ import { createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, mergeProps, normalizeClass, onBeforeUnmount, openBlock, ref, unref, useAttrs, useTemplateRef, watch, withCtx } from "vue";
3
3
  import { bem } from "@veltra/utils";
4
4
  //#region src/components/file-viewer/previewers/docx-previewer.vue
5
5
  const _sfc_main = /* @__PURE__ */ defineComponent({
6
6
  name: "FileViewerDocxPreviewer",
7
+ inheritAttrs: false,
7
8
  __name: "docx-previewer",
8
9
  props: { file: {} },
9
10
  emits: ["error"],
@@ -11,6 +12,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
11
12
  const props = __props;
12
13
  const emit = __emit;
13
14
  const cls = bem("file-viewer");
15
+ const attrs = useAttrs();
14
16
  const container = useTemplateRef("container");
15
17
  const loading = ref(true);
16
18
  let controller;
@@ -53,10 +55,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
53
55
  if (container.value) container.value.innerHTML = "";
54
56
  });
55
57
  return (_ctx, _cache) => {
56
- return openBlock(), createBlock(unref(_sfc_main$1), {
58
+ return openBlock(), createBlock(unref(_sfc_main$1), mergeProps({
57
59
  tag: "div",
58
- class: normalizeClass(unref(cls).e("docx"))
59
- }, {
60
+ class: unref(cls).e("docx")
61
+ }, unref(attrs)), {
60
62
  default: withCtx(() => [createElementVNode("div", {
61
63
  ref_key: "container",
62
64
  ref: container,
@@ -66,7 +68,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
66
68
  class: normalizeClass(unref(cls).e("loading"))
67
69
  }, "加载中…", 2)) : createCommentVNode("v-if", true)]),
68
70
  _: 1
69
- }, 8, ["class"]);
71
+ }, 16, ["class"]);
70
72
  };
71
73
  }
72
74
  });
@@ -1 +1 @@
1
- {"version":3,"file":"docx-previewer.js","names":[],"sources":["../../../../src/components/file-viewer/previewers/docx-previewer.vue"],"sourcesContent":["<template>\n <u-scroll tag=\"div\" :class=\"cls.e('docx')\">\n <div ref=\"container\" :class=\"cls.e('docx-body')\" />\n <div v-if=\"loading\" :class=\"cls.e('loading')\">加载中…</div>\n </u-scroll>\n</template>\n\n<script lang=\"ts\" setup>\nimport { bem } from '@veltra/utils'\nimport { onBeforeUnmount, ref, useTemplateRef, watch } from 'vue'\n\nimport type { FileViewerItem } from '../../../types/file-viewer'\nimport { UScroll } from '../../scroll'\n\ndefineOptions({ name: 'FileViewerDocxPreviewer' })\n\nconst props = defineProps<{ file: FileViewerItem }>()\n\nconst emit = defineEmits<{ (e: 'error', err: unknown): void }>()\n\nconst cls = bem('file-viewer')\n\nconst container = useTemplateRef<HTMLDivElement>('container')\nconst loading = ref(true)\n\nlet controller: AbortController | undefined\n\nasync function load() {\n controller?.abort()\n controller = new AbortController()\n const signal = controller.signal\n loading.value = true\n\n try {\n const [{ toArrayBuffer }, docx] = await Promise.all([\n import('../helper'),\n import('docx-preview')\n ])\n\n const buf = await toArrayBuffer(props.file.src, signal)\n if (signal.aborted) return\n const el = container.value\n if (!el) return\n el.innerHTML = ''\n\n await docx.renderAsync(buf, el, undefined, {\n className: 'u-file-viewer__docx-doc',\n inWrapper: true,\n ignoreWidth: false,\n ignoreHeight: false,\n ignoreFonts: false,\n breakPages: true,\n experimental: false,\n useBase64URL: false,\n renderChanges: false,\n renderHeaders: true,\n renderFooters: true,\n renderFootnotes: true\n })\n } catch (err) {\n if ((err as { name?: string })?.name === 'AbortError') return\n emit('error', err)\n } finally {\n loading.value = false\n }\n}\n\nwatch(\n () => props.file,\n () => load(),\n { immediate: true }\n)\n\nonBeforeUnmount(() => {\n controller?.abort()\n if (container.value) container.value.innerHTML = ''\n})\n</script>\n"],"mappings":";;;;;;;;;;EAgBA,MAAM,QAAQ;EAEd,MAAM,OAAO;EAEb,MAAM,MAAM,IAAI,cAAa;EAE7B,MAAM,YAAY,eAA+B,YAAW;EAC5D,MAAM,UAAU,IAAI,KAAI;EAExB,IAAI;EAEJ,eAAe,OAAO;AACpB,eAAY,OAAM;AAClB,gBAAa,IAAI,iBAAgB;GACjC,MAAM,SAAS,WAAW;AAC1B,WAAQ,QAAQ;AAEhB,OAAI;IACF,MAAM,CAAC,EAAE,iBAAiB,QAAQ,MAAM,QAAQ,IAAI,CAClD,OAAO,iBACP,OAAO,gBACR,CAAA;IAED,MAAM,MAAM,MAAM,cAAc,MAAM,KAAK,KAAK,OAAM;AACtD,QAAI,OAAO,QAAS;IACpB,MAAM,KAAK,UAAU;AACrB,QAAI,CAAC,GAAI;AACT,OAAG,YAAY;AAEf,UAAM,KAAK,YAAY,KAAK,IAAI,KAAA,GAAW;KACzC,WAAW;KACX,WAAW;KACX,aAAa;KACb,cAAc;KACd,aAAa;KACb,YAAY;KACZ,cAAc;KACd,cAAc;KACd,eAAe;KACf,eAAe;KACf,eAAe;KACf,iBAAiB;KAClB,CAAA;YACM,KAAK;AACZ,QAAK,KAA2B,SAAS,aAAc;AACvD,SAAK,SAAS,IAAG;aACT;AACR,YAAQ,QAAQ;;;AAIpB,cACQ,MAAM,YACN,MAAM,EACZ,EAAE,WAAW,MAAK,CACpB;AAEA,wBAAsB;AACpB,eAAY,OAAM;AAClB,OAAI,UAAU,MAAO,WAAU,MAAM,YAAY;IAClD;;uBA3EC,YAGW,MAAA,YAAA,EAAA;IAHD,KAAI;IAAO,OAAK,eAAE,MAAA,IAAG,CAAC,EAAC,OAAA,CAAA;;2BACoB,CAAnD,mBAAmD,OAAA;cAA1C;KAAJ,KAAI;KAAa,OAAK,eAAE,MAAA,IAAG,CAAC,EAAC,YAAA,CAAA;iBACvB,QAAA,SAAA,WAAA,EAAX,mBAAwD,OAAA;;KAAnC,OAAK,eAAE,MAAA,IAAG,CAAC,EAAC,UAAA,CAAA;OAAa,QAAI,EAAA,IAAA,mBAAA,QAAA,KAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"docx-previewer.js","names":[],"sources":["../../../../src/components/file-viewer/previewers/docx-previewer.vue"],"sourcesContent":["<template>\n <u-scroll tag=\"div\" :class=\"cls.e('docx')\" v-bind=\"attrs\">\n <div ref=\"container\" :class=\"cls.e('docx-body')\" />\n <div v-if=\"loading\" :class=\"cls.e('loading')\">加载中…</div>\n </u-scroll>\n</template>\n\n<script lang=\"ts\" setup>\nimport { bem } from '@veltra/utils'\nimport { onBeforeUnmount, ref, useAttrs, useTemplateRef, watch } from 'vue'\n\nimport type { FileViewerItem } from '../../../types/file-viewer'\nimport { UScroll } from '../../scroll'\n\ndefineOptions({ name: 'FileViewerDocxPreviewer', inheritAttrs: false })\n\nconst props = defineProps<{ file: FileViewerItem }>()\n\nconst emit = defineEmits<{ (e: 'error', err: unknown): void }>()\n\nconst cls = bem('file-viewer')\nconst attrs = useAttrs()\n\nconst container = useTemplateRef<HTMLDivElement>('container')\nconst loading = ref(true)\n\nlet controller: AbortController | undefined\n\nasync function load() {\n controller?.abort()\n controller = new AbortController()\n const signal = controller.signal\n loading.value = true\n\n try {\n const [{ toArrayBuffer }, docx] = await Promise.all([\n import('../helper'),\n import('docx-preview')\n ])\n\n const buf = await toArrayBuffer(props.file.src, signal)\n if (signal.aborted) return\n const el = container.value\n if (!el) return\n el.innerHTML = ''\n\n await docx.renderAsync(buf, el, undefined, {\n className: 'u-file-viewer__docx-doc',\n inWrapper: true,\n ignoreWidth: false,\n ignoreHeight: false,\n ignoreFonts: false,\n breakPages: true,\n experimental: false,\n useBase64URL: false,\n renderChanges: false,\n renderHeaders: true,\n renderFooters: true,\n renderFootnotes: true\n })\n } catch (err) {\n if ((err as { name?: string })?.name === 'AbortError') return\n emit('error', err)\n } finally {\n loading.value = false\n }\n}\n\nwatch(\n () => props.file,\n () => load(),\n { immediate: true }\n)\n\nonBeforeUnmount(() => {\n controller?.abort()\n if (container.value) container.value.innerHTML = ''\n})\n</script>\n"],"mappings":";;;;;;;;;;;EAgBA,MAAM,QAAQ;EAEd,MAAM,OAAO;EAEb,MAAM,MAAM,IAAI,cAAa;EAC7B,MAAM,QAAQ,UAAS;EAEvB,MAAM,YAAY,eAA+B,YAAW;EAC5D,MAAM,UAAU,IAAI,KAAI;EAExB,IAAI;EAEJ,eAAe,OAAO;AACpB,eAAY,OAAM;AAClB,gBAAa,IAAI,iBAAgB;GACjC,MAAM,SAAS,WAAW;AAC1B,WAAQ,QAAQ;AAEhB,OAAI;IACF,MAAM,CAAC,EAAE,iBAAiB,QAAQ,MAAM,QAAQ,IAAI,CAClD,OAAO,iBACP,OAAO,gBACR,CAAA;IAED,MAAM,MAAM,MAAM,cAAc,MAAM,KAAK,KAAK,OAAM;AACtD,QAAI,OAAO,QAAS;IACpB,MAAM,KAAK,UAAU;AACrB,QAAI,CAAC,GAAI;AACT,OAAG,YAAY;AAEf,UAAM,KAAK,YAAY,KAAK,IAAI,KAAA,GAAW;KACzC,WAAW;KACX,WAAW;KACX,aAAa;KACb,cAAc;KACd,aAAa;KACb,YAAY;KACZ,cAAc;KACd,cAAc;KACd,eAAe;KACf,eAAe;KACf,eAAe;KACf,iBAAiB;KAClB,CAAA;YACM,KAAK;AACZ,QAAK,KAA2B,SAAS,aAAc;AACvD,SAAK,SAAS,IAAG;aACT;AACR,YAAQ,QAAQ;;;AAIpB,cACQ,MAAM,YACN,MAAM,EACZ,EAAE,WAAW,MAAK,CACpB;AAEA,wBAAsB;AACpB,eAAY,OAAM;AAClB,OAAI,UAAU,MAAO,WAAU,MAAM,YAAY;IAClD;;uBA5EC,YAGW,MAAA,YAAA,EAHX,WAGW;IAHD,KAAI;IAAO,OAAO,MAAA,IAAG,CAAC,EAAC,OAAA;MAAkB,MAAA,MAAK,CAAA,EAAA;2BACH,CAAnD,mBAAmD,OAAA;cAA1C;KAAJ,KAAI;KAAa,OAAK,eAAE,MAAA,IAAG,CAAC,EAAC,YAAA,CAAA;iBACvB,QAAA,SAAA,WAAA,EAAX,mBAAwD,OAAA;;KAAnC,OAAK,eAAE,MAAA,IAAG,CAAC,EAAC,UAAA,CAAA;OAAa,QAAI,EAAA,IAAA,mBAAA,QAAA,KAAA,CAAA,CAAA"}
@@ -1,9 +1,10 @@
1
- import { createCommentVNode, createElementBlock, defineComponent, normalizeClass, onBeforeUnmount, openBlock, ref, shallowRef, unref, watch } from "vue";
1
+ import { createCommentVNode, createElementBlock, defineComponent, mergeProps, normalizeClass, onBeforeUnmount, openBlock, ref, shallowRef, unref, useAttrs, watch } from "vue";
2
2
  import { bem } from "@veltra/utils";
3
3
  //#region src/components/file-viewer/previewers/image-previewer.vue
4
4
  const _hoisted_1 = ["src", "alt"];
5
5
  const _sfc_main = /* @__PURE__ */ defineComponent({
6
6
  name: "FileViewerImagePreviewer",
7
+ inheritAttrs: false,
7
8
  __name: "image-previewer",
8
9
  props: { file: {} },
9
10
  emits: ["error"],
@@ -11,10 +12,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
11
12
  const props = __props;
12
13
  const emit = __emit;
13
14
  const cls = bem("file-viewer");
15
+ const attrs = useAttrs();
14
16
  const url = shallowRef("");
15
17
  const loading = ref(true);
16
18
  const failed = ref(false);
17
- const actual = ref(false);
18
19
  let revoke;
19
20
  async function load() {
20
21
  loading.value = true;
@@ -36,15 +37,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
36
37
  url.value = "";
37
38
  });
38
39
  return (_ctx, _cache) => {
39
- return openBlock(), createElementBlock("div", { class: normalizeClass([unref(cls).e("image"), unref(bem).is("actual", actual.value)]) }, [
40
+ return openBlock(), createElementBlock("div", mergeProps({ class: unref(cls).e("image") }, unref(attrs)), [
40
41
  url.value ? (openBlock(), createElementBlock("img", {
41
42
  key: 0,
42
43
  src: url.value,
43
44
  alt: __props.file.name,
44
45
  draggable: "false",
45
46
  onLoad: _cache[0] || (_cache[0] = ($event) => loading.value = false),
46
- onError: onImgError,
47
- onDblclick: _cache[1] || (_cache[1] = ($event) => actual.value = !actual.value)
47
+ onError: onImgError
48
48
  }, null, 40, _hoisted_1)) : createCommentVNode("v-if", true),
49
49
  loading.value ? (openBlock(), createElementBlock("div", {
50
50
  key: 1,
@@ -54,7 +54,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
54
54
  key: 2,
55
55
  class: normalizeClass(unref(cls).e("loading"))
56
56
  }, "图片加载失败", 2)) : createCommentVNode("v-if", true)
57
- ], 2);
57
+ ], 16);
58
58
  };
59
59
  }
60
60
  });
@@ -1 +1 @@
1
- {"version":3,"file":"image-previewer.js","names":[],"sources":["../../../../src/components/file-viewer/previewers/image-previewer.vue"],"sourcesContent":["<template>\n <div :class=\"[cls.e('image'), bem.is('actual', actual)]\">\n <img\n v-if=\"url\"\n :src=\"url\"\n :alt=\"file.name\"\n draggable=\"false\"\n @load=\"loading = false\"\n @error=\"onImgError\"\n @dblclick=\"actual = !actual\"\n />\n <div v-if=\"loading\" :class=\"cls.e('loading')\">加载中…</div>\n <div v-if=\"failed\" :class=\"cls.e('loading')\">图片加载失败</div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { bem } from '@veltra/utils'\nimport { onBeforeUnmount, ref, shallowRef, watch } from 'vue'\n\nimport type { FileViewerItem } from '../../../types/file-viewer'\n\ndefineOptions({ name: 'FileViewerImagePreviewer' })\n\nconst props = defineProps<{ file: FileViewerItem }>()\n\nconst emit = defineEmits<{ (e: 'error', err: unknown): void }>()\n\nconst cls = bem('file-viewer')\n\nconst url = shallowRef<string>('')\nconst loading = ref(true)\nconst failed = ref(false)\nconst actual = ref(false)\n\nlet revoke: (() => void) | undefined\n\nasync function load() {\n loading.value = true\n failed.value = false\n revoke?.()\n const { toBlobUrl } = await import('../helper')\n const r = toBlobUrl(props.file.src, props.file.mime)\n url.value = r.url\n revoke = r.revoke\n}\n\nfunction onImgError(e: Event) {\n loading.value = false\n failed.value = true\n emit('error', e)\n}\n\nwatch(\n () => props.file,\n () => load(),\n { immediate: true }\n)\n\nonBeforeUnmount(() => {\n revoke?.()\n url.value = ''\n})\n</script>\n"],"mappings":";;;;;;;;;;EAwBA,MAAM,QAAQ;EAEd,MAAM,OAAO;EAEb,MAAM,MAAM,IAAI,cAAa;EAE7B,MAAM,MAAM,WAAmB,GAAE;EACjC,MAAM,UAAU,IAAI,KAAI;EACxB,MAAM,SAAS,IAAI,MAAK;EACxB,MAAM,SAAS,IAAI,MAAK;EAExB,IAAI;EAEJ,eAAe,OAAO;AACpB,WAAQ,QAAQ;AAChB,UAAO,QAAQ;AACf,aAAS;GACT,MAAM,EAAE,cAAc,MAAM,OAAO;GACnC,MAAM,IAAI,UAAU,MAAM,KAAK,KAAK,MAAM,KAAK,KAAI;AACnD,OAAI,QAAQ,EAAE;AACd,YAAS,EAAE;;EAGb,SAAS,WAAW,GAAU;AAC5B,WAAQ,QAAQ;AAChB,UAAO,QAAQ;AACf,QAAK,SAAS,EAAC;;AAGjB,cACQ,MAAM,YACN,MAAM,EACZ,EAAE,WAAW,MAAK,CACpB;AAEA,wBAAsB;AACpB,aAAS;AACT,OAAI,QAAQ;IACb;;uBA7DC,mBAYM,OAAA,EAZA,OAAK,eAAA,CAAG,MAAA,IAAG,CAAC,EAAC,QAAA,EAAW,MAAA,IAAG,CAAC,GAAE,UAAW,OAAA,MAAM,CAAA,CAAA,EAAA,EAAA;IAE3C,IAAA,SAAA,WAAA,EADR,mBAQE,OAAA;;KANC,KAAK,IAAA;KACL,KAAK,QAAA,KAAK;KACX,WAAU;KACT,QAAI,OAAA,OAAA,OAAA,MAAA,WAAE,QAAA,QAAO;KACb,SAAO;KACP,YAAQ,OAAA,OAAA,OAAA,MAAA,WAAE,OAAA,QAAM,CAAI,OAAA;;IAEZ,QAAA,SAAA,WAAA,EAAX,mBAAwD,OAAA;;KAAnC,OAAK,eAAE,MAAA,IAAG,CAAC,EAAC,UAAA,CAAA;OAAa,QAAI,EAAA,IAAA,mBAAA,QAAA,KAAA;IACvC,OAAA,SAAA,WAAA,EAAX,mBAAyD,OAAA;;KAArC,OAAK,eAAE,MAAA,IAAG,CAAC,EAAC,UAAA,CAAA;OAAa,UAAM,EAAA,IAAA,mBAAA,QAAA,KAAA"}
1
+ {"version":3,"file":"image-previewer.js","names":[],"sources":["../../../../src/components/file-viewer/previewers/image-previewer.vue"],"sourcesContent":["<template>\n <div :class=\"cls.e('image')\" v-bind=\"attrs\">\n <img\n v-if=\"url\"\n :src=\"url\"\n :alt=\"file.name\"\n draggable=\"false\"\n @load=\"loading = false\"\n @error=\"onImgError\"\n />\n <div v-if=\"loading\" :class=\"cls.e('loading')\">加载中…</div>\n <div v-if=\"failed\" :class=\"cls.e('loading')\">图片加载失败</div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { bem } from '@veltra/utils'\nimport { onBeforeUnmount, ref, shallowRef, useAttrs, watch } from 'vue'\n\nimport type { FileViewerItem } from '../../../types/file-viewer'\n\ndefineOptions({ name: 'FileViewerImagePreviewer', inheritAttrs: false })\n\nconst props = defineProps<{ file: FileViewerItem }>()\n\nconst emit = defineEmits<{ (e: 'error', err: unknown): void }>()\n\nconst cls = bem('file-viewer')\nconst attrs = useAttrs()\n\nconst url = shallowRef<string>('')\nconst loading = ref(true)\nconst failed = ref(false)\n\nlet revoke: (() => void) | undefined\n\nasync function load() {\n loading.value = true\n failed.value = false\n revoke?.()\n const { toBlobUrl } = await import('../helper')\n const r = toBlobUrl(props.file.src, props.file.mime)\n url.value = r.url\n revoke = r.revoke\n}\n\nfunction onImgError(e: Event) {\n loading.value = false\n failed.value = true\n emit('error', e)\n}\n\nwatch(\n () => props.file,\n () => load(),\n { immediate: true }\n)\n\nonBeforeUnmount(() => {\n revoke?.()\n url.value = ''\n})\n</script>\n"],"mappings":";;;;;;;;;;;EAuBA,MAAM,QAAQ;EAEd,MAAM,OAAO;EAEb,MAAM,MAAM,IAAI,cAAa;EAC7B,MAAM,QAAQ,UAAS;EAEvB,MAAM,MAAM,WAAmB,GAAE;EACjC,MAAM,UAAU,IAAI,KAAI;EACxB,MAAM,SAAS,IAAI,MAAK;EAExB,IAAI;EAEJ,eAAe,OAAO;AACpB,WAAQ,QAAQ;AAChB,UAAO,QAAQ;AACf,aAAS;GACT,MAAM,EAAE,cAAc,MAAM,OAAO;GACnC,MAAM,IAAI,UAAU,MAAM,KAAK,KAAK,MAAM,KAAK,KAAI;AACnD,OAAI,QAAQ,EAAE;AACd,YAAS,EAAE;;EAGb,SAAS,WAAW,GAAU;AAC5B,WAAQ,QAAQ;AAChB,UAAO,QAAQ;AACf,QAAK,SAAS,EAAC;;AAGjB,cACQ,MAAM,YACN,MAAM,EACZ,EAAE,WAAW,MAAK,CACpB;AAEA,wBAAsB;AACpB,aAAS;AACT,OAAI,QAAQ;IACb;;uBA5DC,mBAWM,OAXN,WAWM,EAXA,OAAO,MAAA,IAAG,CAAC,EAAC,QAAA,EAAA,EAAmB,MAAA,MAAK,CAAA,EAAA;IAEhC,IAAA,SAAA,WAAA,EADR,mBAOE,OAAA;;KALC,KAAK,IAAA;KACL,KAAK,QAAA,KAAK;KACX,WAAU;KACT,QAAI,OAAA,OAAA,OAAA,MAAA,WAAE,QAAA,QAAO;KACb,SAAO;;IAEC,QAAA,SAAA,WAAA,EAAX,mBAAwD,OAAA;;KAAnC,OAAK,eAAE,MAAA,IAAG,CAAC,EAAC,UAAA,CAAA;OAAa,QAAI,EAAA,IAAA,mBAAA,QAAA,KAAA;IACvC,OAAA,SAAA,WAAA,EAAX,mBAAyD,OAAA;;KAArC,OAAK,eAAE,MAAA,IAAG,CAAC,EAAC,UAAA,CAAA;OAAa,UAAM,EAAA,IAAA,mBAAA,QAAA,KAAA"}
@@ -1,4 +1,4 @@
1
- import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, onBeforeUnmount, openBlock, shallowRef, unref, watch, withCtx } from "vue";
1
+ import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, mergeProps, normalizeClass, normalizeStyle, onBeforeUnmount, openBlock, shallowRef, unref, useAttrs, watch, withCtx } from "vue";
2
2
  import { bem } from "@veltra/utils";
3
3
  import { createPluginRegistration } from "@embedpdf/core";
4
4
  import { EmbedPDF } from "@embedpdf/core/vue";
@@ -10,6 +10,7 @@ import { Viewport, ViewportPluginPackage } from "@embedpdf/plugin-viewport/vue";
10
10
  //#region src/components/file-viewer/previewers/pdf-previewer.vue
11
11
  const _sfc_main = /* @__PURE__ */ defineComponent({
12
12
  name: "FileViewerPdfPreviewer",
13
+ inheritAttrs: false,
13
14
  __name: "pdf-previewer",
14
15
  props: { file: {} },
15
16
  emits: ["error"],
@@ -17,6 +18,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17
18
  const props = __props;
18
19
  const emit = __emit;
19
20
  const cls = bem("file-viewer");
21
+ const attrs = useAttrs();
20
22
  const { engine, isLoading, error } = usePdfiumEngine();
21
23
  const pdfUrl = shallowRef("");
22
24
  let revoke;
@@ -45,7 +47,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
45
47
  pdfUrl.value = "";
46
48
  });
47
49
  return (_ctx, _cache) => {
48
- return openBlock(), createElementBlock("div", { class: normalizeClass(unref(cls).e("pdf")) }, [!unref(engine) || unref(isLoading) ? (openBlock(), createElementBlock("div", {
50
+ return openBlock(), createElementBlock("div", mergeProps({ class: unref(cls).e("pdf") }, unref(attrs)), [!unref(engine) || unref(isLoading) ? (openBlock(), createElementBlock("div", {
49
51
  key: 0,
50
52
  class: normalizeClass(unref(cls).e("loading"))
51
53
  }, "正在加载 PDF 引擎…", 2)) : pdfUrl.value ? (openBlock(), createBlock(unref(EmbedPDF), {
@@ -80,7 +82,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
80
82
  _: 2
81
83
  }, 1032, ["document-id"])) : createCommentVNode("v-if", true)]),
82
84
  _: 1
83
- }, 8, ["engine", "plugins"])) : createCommentVNode("v-if", true)], 2);
85
+ }, 8, ["engine", "plugins"])) : createCommentVNode("v-if", true)], 16);
84
86
  };
85
87
  }
86
88
  });
@@ -1 +1 @@
1
- {"version":3,"file":"pdf-previewer.js","names":[],"sources":["../../../../src/components/file-viewer/previewers/pdf-previewer.vue"],"sourcesContent":["<template>\n <div :class=\"cls.e('pdf')\">\n <div v-if=\"!engine || isLoading\" :class=\"cls.e('loading')\">正在加载 PDF 引擎…</div>\n <EmbedPDF v-else-if=\"pdfUrl\" :engine=\"engine\" :plugins=\"plugins\" v-slot=\"{ activeDocumentId }\">\n <DocumentContent\n v-if=\"activeDocumentId\"\n :document-id=\"activeDocumentId\"\n v-slot=\"{ isLoaded }\"\n >\n <Viewport v-if=\"isLoaded\" :document-id=\"activeDocumentId\" :class=\"cls.e('pdf-viewport')\">\n <Scroller :document-id=\"activeDocumentId\">\n <template #default=\"{ page }\">\n <div\n :class=\"cls.e('pdf-page')\"\n :style=\"{ width: page.width + 'px', height: page.height + 'px' }\"\n >\n <RenderLayer :document-id=\"activeDocumentId\" :page-index=\"page.pageIndex\" />\n </div>\n </template>\n </Scroller>\n </Viewport>\n </DocumentContent>\n </EmbedPDF>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { createPluginRegistration } from '@embedpdf/core'\nimport { EmbedPDF } from '@embedpdf/core/vue'\nimport { usePdfiumEngine } from '@embedpdf/engines/vue'\nimport {\n DocumentContent,\n DocumentManagerPluginPackage\n} from '@embedpdf/plugin-document-manager/vue'\nimport { RenderLayer, RenderPluginPackage } from '@embedpdf/plugin-render/vue'\nimport { ScrollPluginPackage, Scroller } from '@embedpdf/plugin-scroll/vue'\nimport { ViewportPluginPackage, Viewport } from '@embedpdf/plugin-viewport/vue'\nimport { bem } from '@veltra/utils'\nimport { computed, onBeforeUnmount, shallowRef, watch } from 'vue'\n\nimport type { FileViewerItem } from '../../../types/file-viewer'\n\ndefineOptions({ name: 'FileViewerPdfPreviewer' })\n\nconst props = defineProps<{ file: FileViewerItem }>()\n\nconst emit = defineEmits<{ (e: 'error', err: unknown): void }>()\n\nconst cls = bem('file-viewer')\n\nconst { engine, isLoading, error } = usePdfiumEngine()\n\nconst pdfUrl = shallowRef<string>('')\nlet revoke: (() => void) | undefined\n\nasync function load() {\n revoke?.()\n const { toBlobUrl } = await import('../helper')\n const r = toBlobUrl(props.file.src, props.file.mime ?? 'application/pdf')\n pdfUrl.value = r.url\n revoke = r.revoke\n}\n\nconst plugins = computed(() => {\n if (!pdfUrl.value) return []\n return [\n createPluginRegistration(DocumentManagerPluginPackage, {\n initialDocuments: [{ url: pdfUrl.value }]\n }),\n createPluginRegistration(ViewportPluginPackage),\n createPluginRegistration(ScrollPluginPackage),\n createPluginRegistration(RenderPluginPackage)\n ]\n})\n\nwatch(\n () => props.file,\n () => load(),\n { immediate: true }\n)\n\nwatch(error, (err) => {\n if (err) emit('error', err)\n})\n\nonBeforeUnmount(() => {\n revoke?.()\n pdfUrl.value =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KAff,eAAa;;uBAcH,EAbD,eAAQ,CAEF,YAAA,WAAA,EAAhB,YAWW,MAAA,SAAA,EAAA;;MAXgB,eAAa;MAAmB,OAAK,eAAE,MAAA,IAAG,CAAC,EAAC,eAAA,CAAA;;6BAU1D,CATX,YASW,MAAA,SAAA,EAAA,EATA,eAAa,kBAAgB,EAAA;OAC3B,SAAO,SAMV,EANc,WAAI,CACxB,mBAKM,OAAA;QAJH,OAAK,eAAE,MAAA,IAAG,CAAC,EAAC,WAAA,CAAA;QACZ,OAAK,eAAA;SAAA,OAAW,KAAK,QAAK;SAAA,QAAiB,KAAK,SAAM;SAAA,CAAA;WAEvD,YAA4E,MAAA,YAAA,EAAA;QAA9D,eAAa;QAAmB,cAAY,KAAK"}
1
+ {"version":3,"file":"pdf-previewer.js","names":[],"sources":["../../../../src/components/file-viewer/previewers/pdf-previewer.vue"],"sourcesContent":["<template>\n <div :class=\"cls.e('pdf')\" v-bind=\"attrs\">\n <div v-if=\"!engine || isLoading\" :class=\"cls.e('loading')\">正在加载 PDF 引擎…</div>\n <EmbedPDF v-else-if=\"pdfUrl\" :engine=\"engine\" :plugins=\"plugins\" v-slot=\"{ activeDocumentId }\">\n <DocumentContent\n v-if=\"activeDocumentId\"\n :document-id=\"activeDocumentId\"\n v-slot=\"{ isLoaded }\"\n >\n <Viewport v-if=\"isLoaded\" :document-id=\"activeDocumentId\" :class=\"cls.e('pdf-viewport')\">\n <Scroller :document-id=\"activeDocumentId\">\n <template #default=\"{ page }\">\n <div\n :class=\"cls.e('pdf-page')\"\n :style=\"{ width: page.width + 'px', height: page.height + 'px' }\"\n >\n <RenderLayer :document-id=\"activeDocumentId\" :page-index=\"page.pageIndex\" />\n </div>\n </template>\n </Scroller>\n </Viewport>\n </DocumentContent>\n </EmbedPDF>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { createPluginRegistration } from '@embedpdf/core'\nimport { EmbedPDF } from '@embedpdf/core/vue'\nimport { usePdfiumEngine } from '@embedpdf/engines/vue'\nimport {\n DocumentContent,\n DocumentManagerPluginPackage\n} from '@embedpdf/plugin-document-manager/vue'\nimport { RenderLayer, RenderPluginPackage } from '@embedpdf/plugin-render/vue'\nimport { ScrollPluginPackage, Scroller } from '@embedpdf/plugin-scroll/vue'\nimport { ViewportPluginPackage, Viewport } from '@embedpdf/plugin-viewport/vue'\nimport { bem } from '@veltra/utils'\nimport { computed, onBeforeUnmount, shallowRef, useAttrs, watch } from 'vue'\n\nimport type { FileViewerItem } from '../../../types/file-viewer'\n\ndefineOptions({ name: 'FileViewerPdfPreviewer', inheritAttrs: false })\n\nconst props = defineProps<{ file: FileViewerItem }>()\n\nconst emit = defineEmits<{ (e: 'error', err: unknown): void }>()\n\nconst cls = bem('file-viewer')\nconst attrs = useAttrs()\n\nconst { engine, isLoading, error } = usePdfiumEngine()\n\nconst pdfUrl = shallowRef<string>('')\nlet revoke: (() => void) | undefined\n\nasync function load() {\n revoke?.()\n const { toBlobUrl } = await import('../helper')\n const r = toBlobUrl(props.file.src, props.file.mime ?? 'application/pdf')\n pdfUrl.value = r.url\n revoke = r.revoke\n}\n\nconst plugins = computed(() => {\n if (!pdfUrl.value) return []\n return [\n createPluginRegistration(DocumentManagerPluginPackage, {\n initialDocuments: [{ url: pdfUrl.value }]\n }),\n createPluginRegistration(ViewportPluginPackage),\n createPluginRegistration(ScrollPluginPackage),\n createPluginRegistration(RenderPluginPackage)\n ]\n})\n\nwatch(\n () => props.file,\n () => load(),\n { immediate: true }\n)\n\nwatch(error, (err) => {\n if (err) emit('error', err)\n})\n\nonBeforeUnmount(() => {\n revoke?.()\n pdfUrl.value = ''\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;EA4CA,MAAM,QAAQ;EAEd,MAAM,OAAO;EAEb,MAAM,MAAM,IAAI,cAAa;EAC7B,MAAM,QAAQ,UAAS;EAEvB,MAAM,EAAE,QAAQ,WAAW,UAAU,iBAAgB;EAErD,MAAM,SAAS,WAAmB,GAAE;EACpC,IAAI;E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