@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/angular.cjs CHANGED
@@ -2798,13 +2798,28 @@ var MediaPlugin = class {
2798
2798
  video.src = url;
2799
2799
  video.controls = true;
2800
2800
  video.playsInline = true;
2801
- video.style.maxWidth = "90%";
2802
- video.style.maxHeight = "90%";
2803
2801
  video.style.borderRadius = "8px";
2804
2802
  video.style.boxShadow = "0 8px 30px rgba(0,0,0,0.3)";
2805
2803
  video.style.backgroundColor = "#000000";
2804
+ video.style.objectFit = "contain";
2805
+ video.style.transition = "transform 0.2s ease";
2806
2806
  element = video;
2807
2807
  mediaElement = video;
2808
+ const onMeta = () => {
2809
+ if (video.videoWidth > 0 && video.videoHeight > 0) {
2810
+ naturalW = video.videoWidth;
2811
+ naturalH = video.videoHeight;
2812
+ }
2813
+ updateBaseDimensions();
2814
+ applyTransform();
2815
+ };
2816
+ if (video.readyState >= 1 && video.videoWidth > 0) {
2817
+ naturalW = video.videoWidth;
2818
+ naturalH = video.videoHeight;
2819
+ } else {
2820
+ video.addEventListener("loadedmetadata", onMeta, { once: true });
2821
+ video.addEventListener("canplay", onMeta, { once: true });
2822
+ }
2808
2823
  } else if (isAudio) {
2809
2824
  const audio = document.createElement("audio");
2810
2825
  audio.src = url;
@@ -2845,11 +2860,19 @@ var MediaPlugin = class {
2845
2860
  let fitMode = ctx?.options?.fitMode || "width";
2846
2861
  let isUserZoomed = false;
2847
2862
  const updateBaseDimensions = () => {
2848
- if (!isImage) return;
2849
- const img = element;
2850
- if (img.naturalWidth > 0 && img.naturalHeight > 0) {
2851
- naturalW = img.naturalWidth;
2852
- naturalH = img.naturalHeight;
2863
+ if (!isImage && !isVideo) return;
2864
+ if (isImage) {
2865
+ const img = element;
2866
+ if (img.naturalWidth > 0 && img.naturalHeight > 0) {
2867
+ naturalW = img.naturalWidth;
2868
+ naturalH = img.naturalHeight;
2869
+ }
2870
+ } else if (isVideo) {
2871
+ const vid = element;
2872
+ if (vid.videoWidth > 0 && vid.videoHeight > 0) {
2873
+ naturalW = vid.videoWidth;
2874
+ naturalH = vid.videoHeight;
2875
+ }
2853
2876
  }
2854
2877
  const availW = Math.max(100, ctx.container.clientWidth - 32);
2855
2878
  const availH = Math.max(100, ctx.container.clientHeight - 32);
@@ -2863,7 +2886,7 @@ var MediaPlugin = class {
2863
2886
  baseH = Math.max(1, Math.round(naturalH * fitRatio));
2864
2887
  };
2865
2888
  const applyTransform = () => {
2866
- if (isImage) {
2889
+ if (isImage || isVideo) {
2867
2890
  if (!isUserZoomed) {
2868
2891
  updateBaseDimensions();
2869
2892
  }
@@ -2874,10 +2897,10 @@ var MediaPlugin = class {
2874
2897
  sizer.style.width = `${boxW}px`;
2875
2898
  sizer.style.height = `${boxH}px`;
2876
2899
  sizer.style.margin = boxH < availH ? "auto 0" : "0";
2877
- const imgW = isRotated90 ? boxH : boxW;
2878
- const imgH = isRotated90 ? boxW : boxH;
2879
- element.style.width = `${imgW}px`;
2880
- element.style.height = `${imgH}px`;
2900
+ const elW = isRotated90 ? boxH : boxW;
2901
+ const elH = isRotated90 ? boxW : boxH;
2902
+ element.style.width = `${elW}px`;
2903
+ element.style.height = `${elH}px`;
2881
2904
  element.style.maxWidth = "none";
2882
2905
  element.style.maxHeight = "none";
2883
2906
  element.style.transform = rotation ? `rotate(${rotation}deg)` : "none";
@@ -2887,6 +2910,8 @@ var MediaPlugin = class {
2887
2910
  element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2888
2911
  }
2889
2912
  };
2913
+ updateBaseDimensions();
2914
+ applyTransform();
2890
2915
  if (isImage) {
2891
2916
  const img = element;
2892
2917
  if (img.complete && img.naturalWidth > 0) {
@@ -2931,7 +2956,7 @@ var MediaPlugin = class {
2931
2956
  currentZoom = level;
2932
2957
  applyTransform();
2933
2958
  } : void 0,
2934
- fitToPage: isImage ? () => {
2959
+ fitToPage: isImage || isVideo ? () => {
2935
2960
  isUserZoomed = false;
2936
2961
  fitMode = "page";
2937
2962
  currentZoom = 1;
@@ -2941,7 +2966,7 @@ var MediaPlugin = class {
2941
2966
  updateBaseDimensions();
2942
2967
  applyTransform();
2943
2968
  } : void 0,
2944
- fitToWidth: isImage ? () => {
2969
+ fitToWidth: isImage || isVideo ? () => {
2945
2970
  isUserZoomed = false;
2946
2971
  fitMode = "width";
2947
2972
  currentZoom = 1;
@@ -2951,7 +2976,7 @@ var MediaPlugin = class {
2951
2976
  updateBaseDimensions();
2952
2977
  applyTransform();
2953
2978
  } : void 0,
2954
- resetZoom: isImage ? () => {
2979
+ resetZoom: isImage || isVideo ? () => {
2955
2980
  isUserZoomed = false;
2956
2981
  fitMode = ctx?.options?.fitMode || "width";
2957
2982
  currentZoom = 1;
@@ -4854,6 +4879,36 @@ var CodePlugin = class {
4854
4879
  pre.style.transition = "transform 0.15s ease";
4855
4880
  pre.style.flexShrink = "0";
4856
4881
  } else {
4882
+ if (typeof document !== "undefined" && !document.getElementById("fp-code-syntax-styles")) {
4883
+ const style = document.createElement("style");
4884
+ style.id = "fp-code-syntax-styles";
4885
+ style.textContent = `
4886
+ .fp-code-scroll-wrapper .hljs-keyword { color: #569cd6; font-weight: normal; }
4887
+ .fp-code-scroll-wrapper .hljs-built_in { color: #4ec9b0; }
4888
+ .fp-code-scroll-wrapper .hljs-type { color: #4ec9b0; }
4889
+ .fp-code-scroll-wrapper .hljs-literal { color: #569cd6; }
4890
+ .fp-code-scroll-wrapper .hljs-number { color: #b5cea8; }
4891
+ .fp-code-scroll-wrapper .hljs-regexp { color: #d16969; }
4892
+ .fp-code-scroll-wrapper .hljs-string { color: #ce9178; }
4893
+ .fp-code-scroll-wrapper .hljs-subst { color: #d4d4d4; }
4894
+ .fp-code-scroll-wrapper .hljs-symbol { color: #569cd6; }
4895
+ .fp-code-scroll-wrapper .hljs-class { color: #4ec9b0; }
4896
+ .fp-code-scroll-wrapper .hljs-function { color: #dcdcaa; }
4897
+ .fp-code-scroll-wrapper .hljs-title { color: #dcdcaa; }
4898
+ .fp-code-scroll-wrapper .hljs-params { color: #9cdcfe; }
4899
+ .fp-code-scroll-wrapper .hljs-comment { color: #6a9955; font-style: italic; }
4900
+ .fp-code-scroll-wrapper .hljs-doctag { color: #608b4e; }
4901
+ .fp-code-scroll-wrapper .hljs-meta { color: #9cdcfe; }
4902
+ .fp-code-scroll-wrapper .hljs-section { color: #569cd6; }
4903
+ .fp-code-scroll-wrapper .hljs-tag { color: #569cd6; }
4904
+ .fp-code-scroll-wrapper .hljs-name { color: #569cd6; }
4905
+ .fp-code-scroll-wrapper .hljs-attr { color: #9cdcfe; }
4906
+ .fp-code-scroll-wrapper .hljs-attribute { color: #9cdcfe; }
4907
+ .fp-code-scroll-wrapper .hljs-variable { color: #9cdcfe; }
4908
+ .fp-code-scroll-wrapper .hljs-punctuation { color: #d4d4d4; }
4909
+ `;
4910
+ document.head.appendChild(style);
4911
+ }
4857
4912
  ctx.container.style.backgroundColor = "#1e1e1e";
4858
4913
  ctx.container.style.color = "#d4d4d4";
4859
4914
  scrollWrapper.className = "fp-code-scroll-wrapper";
@@ -4863,9 +4918,13 @@ var CodePlugin = class {
4863
4918
  scrollWrapper.style.height = "max-content";
4864
4919
  scrollWrapper.style.display = "flex";
4865
4920
  scrollWrapper.style.alignItems = "flex-start";
4866
- scrollWrapper.style.padding = "16px";
4921
+ scrollWrapper.style.padding = "16px 16px 16px 0";
4867
4922
  scrollWrapper.style.boxSizing = "border-box";
4868
- const lineCount = fullText.split(/\r?\n/).length || 1;
4923
+ const rawLines = fullText.split(/\r?\n/);
4924
+ if (rawLines.length > 1 && rawLines[rawLines.length - 1] === "") {
4925
+ rawLines.pop();
4926
+ }
4927
+ const lineCount = Math.max(1, rawLines.length);
4869
4928
  const gutterLines = [];
4870
4929
  for (let i = 1; i <= lineCount; i++) {
4871
4930
  gutterLines.push(String(i));
@@ -4873,16 +4932,23 @@ var CodePlugin = class {
4873
4932
  lineGutter.className = "fp-code-gutter";
4874
4933
  lineGutter.style.userSelect = "none";
4875
4934
  lineGutter.style.textAlign = "right";
4876
- lineGutter.style.paddingRight = "16px";
4877
- lineGutter.style.marginRight = "16px";
4935
+ lineGutter.style.padding = "0 16px";
4936
+ lineGutter.style.margin = "0 16px 0 0";
4878
4937
  lineGutter.style.borderRight = "1px solid #333333";
4879
4938
  lineGutter.style.color = "#858585";
4880
4939
  lineGutter.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
4881
4940
  lineGutter.style.fontSize = `${fontSize}px`;
4882
4941
  lineGutter.style.lineHeight = "1.6";
4942
+ lineGutter.style.whiteSpace = "pre";
4883
4943
  lineGutter.style.flexShrink = "0";
4944
+ lineGutter.style.position = "sticky";
4945
+ lineGutter.style.left = "0";
4946
+ lineGutter.style.backgroundColor = "#1e1e1e";
4947
+ lineGutter.style.zIndex = "2";
4948
+ lineGutter.style.boxSizing = "border-box";
4884
4949
  lineGutter.textContent = gutterLines.join("\n");
4885
4950
  pre.style.margin = "0";
4951
+ pre.style.padding = "0 16px 0 0";
4886
4952
  pre.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
4887
4953
  pre.style.fontSize = `${fontSize}px`;
4888
4954
  pre.style.lineHeight = "1.6";
@@ -4890,6 +4956,11 @@ var CodePlugin = class {
4890
4956
  pre.style.wordBreak = "normal";
4891
4957
  pre.style.overflowWrap = "normal";
4892
4958
  pre.style.flex = "1";
4959
+ code.style.display = "block";
4960
+ code.style.fontFamily = "inherit";
4961
+ code.style.fontSize = "inherit";
4962
+ code.style.lineHeight = "inherit";
4963
+ code.style.whiteSpace = "inherit";
4893
4964
  }
4894
4965
  const ext = (ctx.metadata.extension || "").replace(".", "");
4895
4966
  const renderCodePage = (text) => {