@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.js CHANGED
@@ -4857,6 +4857,36 @@ var CodePlugin = class {
4857
4857
  pre.style.transition = "transform 0.15s ease";
4858
4858
  pre.style.flexShrink = "0";
4859
4859
  } else {
4860
+ if (typeof document !== "undefined" && !document.getElementById("fp-code-syntax-styles")) {
4861
+ const style = document.createElement("style");
4862
+ style.id = "fp-code-syntax-styles";
4863
+ style.textContent = `
4864
+ .fp-code-scroll-wrapper .hljs-keyword { color: #569cd6; font-weight: normal; }
4865
+ .fp-code-scroll-wrapper .hljs-built_in { color: #4ec9b0; }
4866
+ .fp-code-scroll-wrapper .hljs-type { color: #4ec9b0; }
4867
+ .fp-code-scroll-wrapper .hljs-literal { color: #569cd6; }
4868
+ .fp-code-scroll-wrapper .hljs-number { color: #b5cea8; }
4869
+ .fp-code-scroll-wrapper .hljs-regexp { color: #d16969; }
4870
+ .fp-code-scroll-wrapper .hljs-string { color: #ce9178; }
4871
+ .fp-code-scroll-wrapper .hljs-subst { color: #d4d4d4; }
4872
+ .fp-code-scroll-wrapper .hljs-symbol { color: #569cd6; }
4873
+ .fp-code-scroll-wrapper .hljs-class { color: #4ec9b0; }
4874
+ .fp-code-scroll-wrapper .hljs-function { color: #dcdcaa; }
4875
+ .fp-code-scroll-wrapper .hljs-title { color: #dcdcaa; }
4876
+ .fp-code-scroll-wrapper .hljs-params { color: #9cdcfe; }
4877
+ .fp-code-scroll-wrapper .hljs-comment { color: #6a9955; font-style: italic; }
4878
+ .fp-code-scroll-wrapper .hljs-doctag { color: #608b4e; }
4879
+ .fp-code-scroll-wrapper .hljs-meta { color: #9cdcfe; }
4880
+ .fp-code-scroll-wrapper .hljs-section { color: #569cd6; }
4881
+ .fp-code-scroll-wrapper .hljs-tag { color: #569cd6; }
4882
+ .fp-code-scroll-wrapper .hljs-name { color: #569cd6; }
4883
+ .fp-code-scroll-wrapper .hljs-attr { color: #9cdcfe; }
4884
+ .fp-code-scroll-wrapper .hljs-attribute { color: #9cdcfe; }
4885
+ .fp-code-scroll-wrapper .hljs-variable { color: #9cdcfe; }
4886
+ .fp-code-scroll-wrapper .hljs-punctuation { color: #d4d4d4; }
4887
+ `;
4888
+ document.head.appendChild(style);
4889
+ }
4860
4890
  ctx.container.style.backgroundColor = "#1e1e1e";
4861
4891
  ctx.container.style.color = "#d4d4d4";
4862
4892
  scrollWrapper.className = "fp-code-scroll-wrapper";
@@ -4866,9 +4896,13 @@ var CodePlugin = class {
4866
4896
  scrollWrapper.style.height = "max-content";
4867
4897
  scrollWrapper.style.display = "flex";
4868
4898
  scrollWrapper.style.alignItems = "flex-start";
4869
- scrollWrapper.style.padding = "16px";
4899
+ scrollWrapper.style.padding = "16px 16px 16px 0";
4870
4900
  scrollWrapper.style.boxSizing = "border-box";
4871
- const lineCount = fullText.split(/\r?\n/).length || 1;
4901
+ const rawLines = fullText.split(/\r?\n/);
4902
+ if (rawLines.length > 1 && rawLines[rawLines.length - 1] === "") {
4903
+ rawLines.pop();
4904
+ }
4905
+ const lineCount = Math.max(1, rawLines.length);
4872
4906
  const gutterLines = [];
4873
4907
  for (let i = 1; i <= lineCount; i++) {
4874
4908
  gutterLines.push(String(i));
@@ -4876,16 +4910,23 @@ var CodePlugin = class {
4876
4910
  lineGutter.className = "fp-code-gutter";
4877
4911
  lineGutter.style.userSelect = "none";
4878
4912
  lineGutter.style.textAlign = "right";
4879
- lineGutter.style.paddingRight = "16px";
4880
- lineGutter.style.marginRight = "16px";
4913
+ lineGutter.style.padding = "0 16px";
4914
+ lineGutter.style.margin = "0 16px 0 0";
4881
4915
  lineGutter.style.borderRight = "1px solid #333333";
4882
4916
  lineGutter.style.color = "#858585";
4883
4917
  lineGutter.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
4884
4918
  lineGutter.style.fontSize = `${fontSize}px`;
4885
4919
  lineGutter.style.lineHeight = "1.6";
4920
+ lineGutter.style.whiteSpace = "pre";
4886
4921
  lineGutter.style.flexShrink = "0";
4922
+ lineGutter.style.position = "sticky";
4923
+ lineGutter.style.left = "0";
4924
+ lineGutter.style.backgroundColor = "#1e1e1e";
4925
+ lineGutter.style.zIndex = "2";
4926
+ lineGutter.style.boxSizing = "border-box";
4887
4927
  lineGutter.textContent = gutterLines.join("\n");
4888
4928
  pre.style.margin = "0";
4929
+ pre.style.padding = "0 16px 0 0";
4889
4930
  pre.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
4890
4931
  pre.style.fontSize = `${fontSize}px`;
4891
4932
  pre.style.lineHeight = "1.6";
@@ -4893,6 +4934,11 @@ var CodePlugin = class {
4893
4934
  pre.style.wordBreak = "normal";
4894
4935
  pre.style.overflowWrap = "normal";
4895
4936
  pre.style.flex = "1";
4937
+ code.style.display = "block";
4938
+ code.style.fontFamily = "inherit";
4939
+ code.style.fontSize = "inherit";
4940
+ code.style.lineHeight = "inherit";
4941
+ code.style.whiteSpace = "inherit";
4896
4942
  }
4897
4943
  const ext = (ctx.metadata.extension || "").replace(".", "");
4898
4944
  const renderCodePage = (text) => {