@files-preview-app/preview-file 1.3.9 → 1.3.10

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/index.cjs CHANGED
@@ -4888,6 +4888,36 @@ var CodePlugin = class {
4888
4888
  pre.style.transition = "transform 0.15s ease";
4889
4889
  pre.style.flexShrink = "0";
4890
4890
  } else {
4891
+ if (typeof document !== "undefined" && !document.getElementById("fp-code-syntax-styles")) {
4892
+ const style = document.createElement("style");
4893
+ style.id = "fp-code-syntax-styles";
4894
+ style.textContent = `
4895
+ .fp-code-scroll-wrapper .hljs-keyword { color: #569cd6; font-weight: normal; }
4896
+ .fp-code-scroll-wrapper .hljs-built_in { color: #4ec9b0; }
4897
+ .fp-code-scroll-wrapper .hljs-type { color: #4ec9b0; }
4898
+ .fp-code-scroll-wrapper .hljs-literal { color: #569cd6; }
4899
+ .fp-code-scroll-wrapper .hljs-number { color: #b5cea8; }
4900
+ .fp-code-scroll-wrapper .hljs-regexp { color: #d16969; }
4901
+ .fp-code-scroll-wrapper .hljs-string { color: #ce9178; }
4902
+ .fp-code-scroll-wrapper .hljs-subst { color: #d4d4d4; }
4903
+ .fp-code-scroll-wrapper .hljs-symbol { color: #569cd6; }
4904
+ .fp-code-scroll-wrapper .hljs-class { color: #4ec9b0; }
4905
+ .fp-code-scroll-wrapper .hljs-function { color: #dcdcaa; }
4906
+ .fp-code-scroll-wrapper .hljs-title { color: #dcdcaa; }
4907
+ .fp-code-scroll-wrapper .hljs-params { color: #9cdcfe; }
4908
+ .fp-code-scroll-wrapper .hljs-comment { color: #6a9955; font-style: italic; }
4909
+ .fp-code-scroll-wrapper .hljs-doctag { color: #608b4e; }
4910
+ .fp-code-scroll-wrapper .hljs-meta { color: #9cdcfe; }
4911
+ .fp-code-scroll-wrapper .hljs-section { color: #569cd6; }
4912
+ .fp-code-scroll-wrapper .hljs-tag { color: #569cd6; }
4913
+ .fp-code-scroll-wrapper .hljs-name { color: #569cd6; }
4914
+ .fp-code-scroll-wrapper .hljs-attr { color: #9cdcfe; }
4915
+ .fp-code-scroll-wrapper .hljs-attribute { color: #9cdcfe; }
4916
+ .fp-code-scroll-wrapper .hljs-variable { color: #9cdcfe; }
4917
+ .fp-code-scroll-wrapper .hljs-punctuation { color: #d4d4d4; }
4918
+ `;
4919
+ document.head.appendChild(style);
4920
+ }
4891
4921
  ctx.container.style.backgroundColor = "#1e1e1e";
4892
4922
  ctx.container.style.color = "#d4d4d4";
4893
4923
  scrollWrapper.className = "fp-code-scroll-wrapper";
@@ -4897,9 +4927,13 @@ var CodePlugin = class {
4897
4927
  scrollWrapper.style.height = "max-content";
4898
4928
  scrollWrapper.style.display = "flex";
4899
4929
  scrollWrapper.style.alignItems = "flex-start";
4900
- scrollWrapper.style.padding = "16px";
4930
+ scrollWrapper.style.padding = "16px 16px 16px 0";
4901
4931
  scrollWrapper.style.boxSizing = "border-box";
4902
- const lineCount = fullText.split(/\r?\n/).length || 1;
4932
+ const rawLines = fullText.split(/\r?\n/);
4933
+ if (rawLines.length > 1 && rawLines[rawLines.length - 1] === "") {
4934
+ rawLines.pop();
4935
+ }
4936
+ const lineCount = Math.max(1, rawLines.length);
4903
4937
  const gutterLines = [];
4904
4938
  for (let i = 1; i <= lineCount; i++) {
4905
4939
  gutterLines.push(String(i));
@@ -4907,16 +4941,23 @@ var CodePlugin = class {
4907
4941
  lineGutter.className = "fp-code-gutter";
4908
4942
  lineGutter.style.userSelect = "none";
4909
4943
  lineGutter.style.textAlign = "right";
4910
- lineGutter.style.paddingRight = "16px";
4911
- lineGutter.style.marginRight = "16px";
4944
+ lineGutter.style.padding = "0 16px";
4945
+ lineGutter.style.margin = "0 16px 0 0";
4912
4946
  lineGutter.style.borderRight = "1px solid #333333";
4913
4947
  lineGutter.style.color = "#858585";
4914
4948
  lineGutter.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
4915
4949
  lineGutter.style.fontSize = `${fontSize}px`;
4916
4950
  lineGutter.style.lineHeight = "1.6";
4951
+ lineGutter.style.whiteSpace = "pre";
4917
4952
  lineGutter.style.flexShrink = "0";
4953
+ lineGutter.style.position = "sticky";
4954
+ lineGutter.style.left = "0";
4955
+ lineGutter.style.backgroundColor = "#1e1e1e";
4956
+ lineGutter.style.zIndex = "2";
4957
+ lineGutter.style.boxSizing = "border-box";
4918
4958
  lineGutter.textContent = gutterLines.join("\n");
4919
4959
  pre.style.margin = "0";
4960
+ pre.style.padding = "0 16px 0 0";
4920
4961
  pre.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
4921
4962
  pre.style.fontSize = `${fontSize}px`;
4922
4963
  pre.style.lineHeight = "1.6";
@@ -4924,6 +4965,11 @@ var CodePlugin = class {
4924
4965
  pre.style.wordBreak = "normal";
4925
4966
  pre.style.overflowWrap = "normal";
4926
4967
  pre.style.flex = "1";
4968
+ code.style.display = "block";
4969
+ code.style.fontFamily = "inherit";
4970
+ code.style.fontSize = "inherit";
4971
+ code.style.lineHeight = "inherit";
4972
+ code.style.whiteSpace = "inherit";
4927
4973
  }
4928
4974
  const ext = (ctx.metadata.extension || "").replace(".", "");
4929
4975
  const renderCodePage = (text) => {