@files-preview-app/preview-file 1.3.9 → 1.3.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.
package/dist/vue.d.cts CHANGED
@@ -34,10 +34,10 @@ declare const FilePreview: vue.DefineComponent<vue.ExtractPropTypes<{
34
34
  onLoading?: ((...args: any[]) => any) | undefined;
35
35
  onLoaded?: ((...args: any[]) => any) | undefined;
36
36
  onError?: ((...args: any[]) => any) | undefined;
37
- onRotate?: ((...args: any[]) => any) | undefined;
38
- onDestroy?: ((...args: any[]) => any) | undefined;
39
37
  "onPage-change"?: ((...args: any[]) => any) | undefined;
40
38
  "onZoom-change"?: ((...args: any[]) => any) | undefined;
39
+ onRotate?: ((...args: any[]) => any) | undefined;
40
+ onDestroy?: ((...args: any[]) => any) | undefined;
41
41
  }>, {
42
42
  plugins: PreviewPlugin[];
43
43
  options: PreviewViewerOptions;
package/dist/vue.d.ts CHANGED
@@ -34,10 +34,10 @@ declare const FilePreview: vue.DefineComponent<vue.ExtractPropTypes<{
34
34
  onLoading?: ((...args: any[]) => any) | undefined;
35
35
  onLoaded?: ((...args: any[]) => any) | undefined;
36
36
  onError?: ((...args: any[]) => any) | undefined;
37
- onRotate?: ((...args: any[]) => any) | undefined;
38
- onDestroy?: ((...args: any[]) => any) | undefined;
39
37
  "onPage-change"?: ((...args: any[]) => any) | undefined;
40
38
  "onZoom-change"?: ((...args: any[]) => any) | undefined;
39
+ onRotate?: ((...args: any[]) => any) | undefined;
40
+ onDestroy?: ((...args: any[]) => any) | undefined;
41
41
  }>, {
42
42
  plugins: PreviewPlugin[];
43
43
  options: PreviewViewerOptions;
package/dist/vue.js CHANGED
@@ -2717,13 +2717,28 @@ var MediaPlugin = class {
2717
2717
  video.src = url;
2718
2718
  video.controls = true;
2719
2719
  video.playsInline = true;
2720
- video.style.maxWidth = "90%";
2721
- video.style.maxHeight = "90%";
2722
2720
  video.style.borderRadius = "8px";
2723
2721
  video.style.boxShadow = "0 8px 30px rgba(0,0,0,0.3)";
2724
2722
  video.style.backgroundColor = "#000000";
2723
+ video.style.objectFit = "contain";
2724
+ video.style.transition = "transform 0.2s ease";
2725
2725
  element = video;
2726
2726
  mediaElement = video;
2727
+ const onMeta = () => {
2728
+ if (video.videoWidth > 0 && video.videoHeight > 0) {
2729
+ naturalW = video.videoWidth;
2730
+ naturalH = video.videoHeight;
2731
+ }
2732
+ updateBaseDimensions();
2733
+ applyTransform();
2734
+ };
2735
+ if (video.readyState >= 1 && video.videoWidth > 0) {
2736
+ naturalW = video.videoWidth;
2737
+ naturalH = video.videoHeight;
2738
+ } else {
2739
+ video.addEventListener("loadedmetadata", onMeta, { once: true });
2740
+ video.addEventListener("canplay", onMeta, { once: true });
2741
+ }
2727
2742
  } else if (isAudio) {
2728
2743
  const audio = document.createElement("audio");
2729
2744
  audio.src = url;
@@ -2764,11 +2779,19 @@ var MediaPlugin = class {
2764
2779
  let fitMode = ctx?.options?.fitMode || "width";
2765
2780
  let isUserZoomed = false;
2766
2781
  const updateBaseDimensions = () => {
2767
- if (!isImage) return;
2768
- const img = element;
2769
- if (img.naturalWidth > 0 && img.naturalHeight > 0) {
2770
- naturalW = img.naturalWidth;
2771
- naturalH = img.naturalHeight;
2782
+ if (!isImage && !isVideo) return;
2783
+ if (isImage) {
2784
+ const img = element;
2785
+ if (img.naturalWidth > 0 && img.naturalHeight > 0) {
2786
+ naturalW = img.naturalWidth;
2787
+ naturalH = img.naturalHeight;
2788
+ }
2789
+ } else if (isVideo) {
2790
+ const vid = element;
2791
+ if (vid.videoWidth > 0 && vid.videoHeight > 0) {
2792
+ naturalW = vid.videoWidth;
2793
+ naturalH = vid.videoHeight;
2794
+ }
2772
2795
  }
2773
2796
  const availW = Math.max(100, ctx.container.clientWidth - 32);
2774
2797
  const availH = Math.max(100, ctx.container.clientHeight - 32);
@@ -2782,7 +2805,7 @@ var MediaPlugin = class {
2782
2805
  baseH = Math.max(1, Math.round(naturalH * fitRatio));
2783
2806
  };
2784
2807
  const applyTransform = () => {
2785
- if (isImage) {
2808
+ if (isImage || isVideo) {
2786
2809
  if (!isUserZoomed) {
2787
2810
  updateBaseDimensions();
2788
2811
  }
@@ -2793,10 +2816,10 @@ var MediaPlugin = class {
2793
2816
  sizer.style.width = `${boxW}px`;
2794
2817
  sizer.style.height = `${boxH}px`;
2795
2818
  sizer.style.margin = boxH < availH ? "auto 0" : "0";
2796
- const imgW = isRotated90 ? boxH : boxW;
2797
- const imgH = isRotated90 ? boxW : boxH;
2798
- element.style.width = `${imgW}px`;
2799
- element.style.height = `${imgH}px`;
2819
+ const elW = isRotated90 ? boxH : boxW;
2820
+ const elH = isRotated90 ? boxW : boxH;
2821
+ element.style.width = `${elW}px`;
2822
+ element.style.height = `${elH}px`;
2800
2823
  element.style.maxWidth = "none";
2801
2824
  element.style.maxHeight = "none";
2802
2825
  element.style.transform = rotation ? `rotate(${rotation}deg)` : "none";
@@ -2806,6 +2829,8 @@ var MediaPlugin = class {
2806
2829
  element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2807
2830
  }
2808
2831
  };
2832
+ updateBaseDimensions();
2833
+ applyTransform();
2809
2834
  if (isImage) {
2810
2835
  const img = element;
2811
2836
  if (img.complete && img.naturalWidth > 0) {
@@ -2850,7 +2875,7 @@ var MediaPlugin = class {
2850
2875
  currentZoom = level;
2851
2876
  applyTransform();
2852
2877
  } : void 0,
2853
- fitToPage: isImage ? () => {
2878
+ fitToPage: isImage || isVideo ? () => {
2854
2879
  isUserZoomed = false;
2855
2880
  fitMode = "page";
2856
2881
  currentZoom = 1;
@@ -2860,7 +2885,7 @@ var MediaPlugin = class {
2860
2885
  updateBaseDimensions();
2861
2886
  applyTransform();
2862
2887
  } : void 0,
2863
- fitToWidth: isImage ? () => {
2888
+ fitToWidth: isImage || isVideo ? () => {
2864
2889
  isUserZoomed = false;
2865
2890
  fitMode = "width";
2866
2891
  currentZoom = 1;
@@ -2870,7 +2895,7 @@ var MediaPlugin = class {
2870
2895
  updateBaseDimensions();
2871
2896
  applyTransform();
2872
2897
  } : void 0,
2873
- resetZoom: isImage ? () => {
2898
+ resetZoom: isImage || isVideo ? () => {
2874
2899
  isUserZoomed = false;
2875
2900
  fitMode = ctx?.options?.fitMode || "width";
2876
2901
  currentZoom = 1;
@@ -4773,6 +4798,36 @@ var CodePlugin = class {
4773
4798
  pre.style.transition = "transform 0.15s ease";
4774
4799
  pre.style.flexShrink = "0";
4775
4800
  } else {
4801
+ if (typeof document !== "undefined" && !document.getElementById("fp-code-syntax-styles")) {
4802
+ const style = document.createElement("style");
4803
+ style.id = "fp-code-syntax-styles";
4804
+ style.textContent = `
4805
+ .fp-code-scroll-wrapper .hljs-keyword { color: #569cd6; font-weight: normal; }
4806
+ .fp-code-scroll-wrapper .hljs-built_in { color: #4ec9b0; }
4807
+ .fp-code-scroll-wrapper .hljs-type { color: #4ec9b0; }
4808
+ .fp-code-scroll-wrapper .hljs-literal { color: #569cd6; }
4809
+ .fp-code-scroll-wrapper .hljs-number { color: #b5cea8; }
4810
+ .fp-code-scroll-wrapper .hljs-regexp { color: #d16969; }
4811
+ .fp-code-scroll-wrapper .hljs-string { color: #ce9178; }
4812
+ .fp-code-scroll-wrapper .hljs-subst { color: #d4d4d4; }
4813
+ .fp-code-scroll-wrapper .hljs-symbol { color: #569cd6; }
4814
+ .fp-code-scroll-wrapper .hljs-class { color: #4ec9b0; }
4815
+ .fp-code-scroll-wrapper .hljs-function { color: #dcdcaa; }
4816
+ .fp-code-scroll-wrapper .hljs-title { color: #dcdcaa; }
4817
+ .fp-code-scroll-wrapper .hljs-params { color: #9cdcfe; }
4818
+ .fp-code-scroll-wrapper .hljs-comment { color: #6a9955; font-style: italic; }
4819
+ .fp-code-scroll-wrapper .hljs-doctag { color: #608b4e; }
4820
+ .fp-code-scroll-wrapper .hljs-meta { color: #9cdcfe; }
4821
+ .fp-code-scroll-wrapper .hljs-section { color: #569cd6; }
4822
+ .fp-code-scroll-wrapper .hljs-tag { color: #569cd6; }
4823
+ .fp-code-scroll-wrapper .hljs-name { color: #569cd6; }
4824
+ .fp-code-scroll-wrapper .hljs-attr { color: #9cdcfe; }
4825
+ .fp-code-scroll-wrapper .hljs-attribute { color: #9cdcfe; }
4826
+ .fp-code-scroll-wrapper .hljs-variable { color: #9cdcfe; }
4827
+ .fp-code-scroll-wrapper .hljs-punctuation { color: #d4d4d4; }
4828
+ `;
4829
+ document.head.appendChild(style);
4830
+ }
4776
4831
  ctx.container.style.backgroundColor = "#1e1e1e";
4777
4832
  ctx.container.style.color = "#d4d4d4";
4778
4833
  scrollWrapper.className = "fp-code-scroll-wrapper";
@@ -4782,9 +4837,13 @@ var CodePlugin = class {
4782
4837
  scrollWrapper.style.height = "max-content";
4783
4838
  scrollWrapper.style.display = "flex";
4784
4839
  scrollWrapper.style.alignItems = "flex-start";
4785
- scrollWrapper.style.padding = "16px";
4840
+ scrollWrapper.style.padding = "16px 16px 16px 0";
4786
4841
  scrollWrapper.style.boxSizing = "border-box";
4787
- const lineCount = fullText.split(/\r?\n/).length || 1;
4842
+ const rawLines = fullText.split(/\r?\n/);
4843
+ if (rawLines.length > 1 && rawLines[rawLines.length - 1] === "") {
4844
+ rawLines.pop();
4845
+ }
4846
+ const lineCount = Math.max(1, rawLines.length);
4788
4847
  const gutterLines = [];
4789
4848
  for (let i = 1; i <= lineCount; i++) {
4790
4849
  gutterLines.push(String(i));
@@ -4792,16 +4851,23 @@ var CodePlugin = class {
4792
4851
  lineGutter.className = "fp-code-gutter";
4793
4852
  lineGutter.style.userSelect = "none";
4794
4853
  lineGutter.style.textAlign = "right";
4795
- lineGutter.style.paddingRight = "16px";
4796
- lineGutter.style.marginRight = "16px";
4854
+ lineGutter.style.padding = "0 16px";
4855
+ lineGutter.style.margin = "0 16px 0 0";
4797
4856
  lineGutter.style.borderRight = "1px solid #333333";
4798
4857
  lineGutter.style.color = "#858585";
4799
4858
  lineGutter.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
4800
4859
  lineGutter.style.fontSize = `${fontSize}px`;
4801
4860
  lineGutter.style.lineHeight = "1.6";
4861
+ lineGutter.style.whiteSpace = "pre";
4802
4862
  lineGutter.style.flexShrink = "0";
4863
+ lineGutter.style.position = "sticky";
4864
+ lineGutter.style.left = "0";
4865
+ lineGutter.style.backgroundColor = "#1e1e1e";
4866
+ lineGutter.style.zIndex = "2";
4867
+ lineGutter.style.boxSizing = "border-box";
4803
4868
  lineGutter.textContent = gutterLines.join("\n");
4804
4869
  pre.style.margin = "0";
4870
+ pre.style.padding = "0 16px 0 0";
4805
4871
  pre.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
4806
4872
  pre.style.fontSize = `${fontSize}px`;
4807
4873
  pre.style.lineHeight = "1.6";
@@ -4809,6 +4875,11 @@ var CodePlugin = class {
4809
4875
  pre.style.wordBreak = "normal";
4810
4876
  pre.style.overflowWrap = "normal";
4811
4877
  pre.style.flex = "1";
4878
+ code.style.display = "block";
4879
+ code.style.fontFamily = "inherit";
4880
+ code.style.fontSize = "inherit";
4881
+ code.style.lineHeight = "inherit";
4882
+ code.style.whiteSpace = "inherit";
4812
4883
  }
4813
4884
  const ext = (ctx.metadata.extension || "").replace(".", "");
4814
4885
  const renderCodePage = (text) => {