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