@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.cjs CHANGED
@@ -2750,13 +2750,28 @@ var MediaPlugin = class {
2750
2750
  video.src = url;
2751
2751
  video.controls = true;
2752
2752
  video.playsInline = true;
2753
- video.style.maxWidth = "90%";
2754
- video.style.maxHeight = "90%";
2755
2753
  video.style.borderRadius = "8px";
2756
2754
  video.style.boxShadow = "0 8px 30px rgba(0,0,0,0.3)";
2757
2755
  video.style.backgroundColor = "#000000";
2756
+ video.style.objectFit = "contain";
2757
+ video.style.transition = "transform 0.2s ease";
2758
2758
  element = video;
2759
2759
  mediaElement = video;
2760
+ const onMeta = () => {
2761
+ if (video.videoWidth > 0 && video.videoHeight > 0) {
2762
+ naturalW = video.videoWidth;
2763
+ naturalH = video.videoHeight;
2764
+ }
2765
+ updateBaseDimensions();
2766
+ applyTransform();
2767
+ };
2768
+ if (video.readyState >= 1 && video.videoWidth > 0) {
2769
+ naturalW = video.videoWidth;
2770
+ naturalH = video.videoHeight;
2771
+ } else {
2772
+ video.addEventListener("loadedmetadata", onMeta, { once: true });
2773
+ video.addEventListener("canplay", onMeta, { once: true });
2774
+ }
2760
2775
  } else if (isAudio) {
2761
2776
  const audio = document.createElement("audio");
2762
2777
  audio.src = url;
@@ -2797,11 +2812,19 @@ var MediaPlugin = class {
2797
2812
  let fitMode = ctx?.options?.fitMode || "width";
2798
2813
  let isUserZoomed = false;
2799
2814
  const updateBaseDimensions = () => {
2800
- if (!isImage) return;
2801
- const img = element;
2802
- if (img.naturalWidth > 0 && img.naturalHeight > 0) {
2803
- naturalW = img.naturalWidth;
2804
- naturalH = img.naturalHeight;
2815
+ if (!isImage && !isVideo) return;
2816
+ if (isImage) {
2817
+ const img = element;
2818
+ if (img.naturalWidth > 0 && img.naturalHeight > 0) {
2819
+ naturalW = img.naturalWidth;
2820
+ naturalH = img.naturalHeight;
2821
+ }
2822
+ } else if (isVideo) {
2823
+ const vid = element;
2824
+ if (vid.videoWidth > 0 && vid.videoHeight > 0) {
2825
+ naturalW = vid.videoWidth;
2826
+ naturalH = vid.videoHeight;
2827
+ }
2805
2828
  }
2806
2829
  const availW = Math.max(100, ctx.container.clientWidth - 32);
2807
2830
  const availH = Math.max(100, ctx.container.clientHeight - 32);
@@ -2815,7 +2838,7 @@ var MediaPlugin = class {
2815
2838
  baseH = Math.max(1, Math.round(naturalH * fitRatio));
2816
2839
  };
2817
2840
  const applyTransform = () => {
2818
- if (isImage) {
2841
+ if (isImage || isVideo) {
2819
2842
  if (!isUserZoomed) {
2820
2843
  updateBaseDimensions();
2821
2844
  }
@@ -2826,10 +2849,10 @@ var MediaPlugin = class {
2826
2849
  sizer.style.width = `${boxW}px`;
2827
2850
  sizer.style.height = `${boxH}px`;
2828
2851
  sizer.style.margin = boxH < availH ? "auto 0" : "0";
2829
- const imgW = isRotated90 ? boxH : boxW;
2830
- const imgH = isRotated90 ? boxW : boxH;
2831
- element.style.width = `${imgW}px`;
2832
- element.style.height = `${imgH}px`;
2852
+ const elW = isRotated90 ? boxH : boxW;
2853
+ const elH = isRotated90 ? boxW : boxH;
2854
+ element.style.width = `${elW}px`;
2855
+ element.style.height = `${elH}px`;
2833
2856
  element.style.maxWidth = "none";
2834
2857
  element.style.maxHeight = "none";
2835
2858
  element.style.transform = rotation ? `rotate(${rotation}deg)` : "none";
@@ -2839,6 +2862,8 @@ var MediaPlugin = class {
2839
2862
  element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2840
2863
  }
2841
2864
  };
2865
+ updateBaseDimensions();
2866
+ applyTransform();
2842
2867
  if (isImage) {
2843
2868
  const img = element;
2844
2869
  if (img.complete && img.naturalWidth > 0) {
@@ -2883,7 +2908,7 @@ var MediaPlugin = class {
2883
2908
  currentZoom = level;
2884
2909
  applyTransform();
2885
2910
  } : void 0,
2886
- fitToPage: isImage ? () => {
2911
+ fitToPage: isImage || isVideo ? () => {
2887
2912
  isUserZoomed = false;
2888
2913
  fitMode = "page";
2889
2914
  currentZoom = 1;
@@ -2893,7 +2918,7 @@ var MediaPlugin = class {
2893
2918
  updateBaseDimensions();
2894
2919
  applyTransform();
2895
2920
  } : void 0,
2896
- fitToWidth: isImage ? () => {
2921
+ fitToWidth: isImage || isVideo ? () => {
2897
2922
  isUserZoomed = false;
2898
2923
  fitMode = "width";
2899
2924
  currentZoom = 1;
@@ -2903,7 +2928,7 @@ var MediaPlugin = class {
2903
2928
  updateBaseDimensions();
2904
2929
  applyTransform();
2905
2930
  } : void 0,
2906
- resetZoom: isImage ? () => {
2931
+ resetZoom: isImage || isVideo ? () => {
2907
2932
  isUserZoomed = false;
2908
2933
  fitMode = ctx?.options?.fitMode || "width";
2909
2934
  currentZoom = 1;
@@ -4806,6 +4831,36 @@ var CodePlugin = class {
4806
4831
  pre.style.transition = "transform 0.15s ease";
4807
4832
  pre.style.flexShrink = "0";
4808
4833
  } else {
4834
+ if (typeof document !== "undefined" && !document.getElementById("fp-code-syntax-styles")) {
4835
+ const style = document.createElement("style");
4836
+ style.id = "fp-code-syntax-styles";
4837
+ style.textContent = `
4838
+ .fp-code-scroll-wrapper .hljs-keyword { color: #569cd6; font-weight: normal; }
4839
+ .fp-code-scroll-wrapper .hljs-built_in { color: #4ec9b0; }
4840
+ .fp-code-scroll-wrapper .hljs-type { color: #4ec9b0; }
4841
+ .fp-code-scroll-wrapper .hljs-literal { color: #569cd6; }
4842
+ .fp-code-scroll-wrapper .hljs-number { color: #b5cea8; }
4843
+ .fp-code-scroll-wrapper .hljs-regexp { color: #d16969; }
4844
+ .fp-code-scroll-wrapper .hljs-string { color: #ce9178; }
4845
+ .fp-code-scroll-wrapper .hljs-subst { color: #d4d4d4; }
4846
+ .fp-code-scroll-wrapper .hljs-symbol { color: #569cd6; }
4847
+ .fp-code-scroll-wrapper .hljs-class { color: #4ec9b0; }
4848
+ .fp-code-scroll-wrapper .hljs-function { color: #dcdcaa; }
4849
+ .fp-code-scroll-wrapper .hljs-title { color: #dcdcaa; }
4850
+ .fp-code-scroll-wrapper .hljs-params { color: #9cdcfe; }
4851
+ .fp-code-scroll-wrapper .hljs-comment { color: #6a9955; font-style: italic; }
4852
+ .fp-code-scroll-wrapper .hljs-doctag { color: #608b4e; }
4853
+ .fp-code-scroll-wrapper .hljs-meta { color: #9cdcfe; }
4854
+ .fp-code-scroll-wrapper .hljs-section { color: #569cd6; }
4855
+ .fp-code-scroll-wrapper .hljs-tag { color: #569cd6; }
4856
+ .fp-code-scroll-wrapper .hljs-name { color: #569cd6; }
4857
+ .fp-code-scroll-wrapper .hljs-attr { color: #9cdcfe; }
4858
+ .fp-code-scroll-wrapper .hljs-attribute { color: #9cdcfe; }
4859
+ .fp-code-scroll-wrapper .hljs-variable { color: #9cdcfe; }
4860
+ .fp-code-scroll-wrapper .hljs-punctuation { color: #d4d4d4; }
4861
+ `;
4862
+ document.head.appendChild(style);
4863
+ }
4809
4864
  ctx.container.style.backgroundColor = "#1e1e1e";
4810
4865
  ctx.container.style.color = "#d4d4d4";
4811
4866
  scrollWrapper.className = "fp-code-scroll-wrapper";
@@ -4815,9 +4870,13 @@ var CodePlugin = class {
4815
4870
  scrollWrapper.style.height = "max-content";
4816
4871
  scrollWrapper.style.display = "flex";
4817
4872
  scrollWrapper.style.alignItems = "flex-start";
4818
- scrollWrapper.style.padding = "16px";
4873
+ scrollWrapper.style.padding = "16px 16px 16px 0";
4819
4874
  scrollWrapper.style.boxSizing = "border-box";
4820
- const lineCount = fullText.split(/\r?\n/).length || 1;
4875
+ const rawLines = fullText.split(/\r?\n/);
4876
+ if (rawLines.length > 1 && rawLines[rawLines.length - 1] === "") {
4877
+ rawLines.pop();
4878
+ }
4879
+ const lineCount = Math.max(1, rawLines.length);
4821
4880
  const gutterLines = [];
4822
4881
  for (let i = 1; i <= lineCount; i++) {
4823
4882
  gutterLines.push(String(i));
@@ -4825,16 +4884,23 @@ var CodePlugin = class {
4825
4884
  lineGutter.className = "fp-code-gutter";
4826
4885
  lineGutter.style.userSelect = "none";
4827
4886
  lineGutter.style.textAlign = "right";
4828
- lineGutter.style.paddingRight = "16px";
4829
- lineGutter.style.marginRight = "16px";
4887
+ lineGutter.style.padding = "0 16px";
4888
+ lineGutter.style.margin = "0 16px 0 0";
4830
4889
  lineGutter.style.borderRight = "1px solid #333333";
4831
4890
  lineGutter.style.color = "#858585";
4832
4891
  lineGutter.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
4833
4892
  lineGutter.style.fontSize = `${fontSize}px`;
4834
4893
  lineGutter.style.lineHeight = "1.6";
4894
+ lineGutter.style.whiteSpace = "pre";
4835
4895
  lineGutter.style.flexShrink = "0";
4896
+ lineGutter.style.position = "sticky";
4897
+ lineGutter.style.left = "0";
4898
+ lineGutter.style.backgroundColor = "#1e1e1e";
4899
+ lineGutter.style.zIndex = "2";
4900
+ lineGutter.style.boxSizing = "border-box";
4836
4901
  lineGutter.textContent = gutterLines.join("\n");
4837
4902
  pre.style.margin = "0";
4903
+ pre.style.padding = "0 16px 0 0";
4838
4904
  pre.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
4839
4905
  pre.style.fontSize = `${fontSize}px`;
4840
4906
  pre.style.lineHeight = "1.6";
@@ -4842,6 +4908,11 @@ var CodePlugin = class {
4842
4908
  pre.style.wordBreak = "normal";
4843
4909
  pre.style.overflowWrap = "normal";
4844
4910
  pre.style.flex = "1";
4911
+ code.style.display = "block";
4912
+ code.style.fontFamily = "inherit";
4913
+ code.style.fontSize = "inherit";
4914
+ code.style.lineHeight = "inherit";
4915
+ code.style.whiteSpace = "inherit";
4845
4916
  }
4846
4917
  const ext = (ctx.metadata.extension || "").replace(".", "");
4847
4918
  const renderCodePage = (text) => {