@files-preview-app/preview-file 1.3.8 → 1.3.9
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 +374 -124
- package/dist/angular.cjs.map +1 -1
- package/dist/angular.js +374 -124
- package/dist/angular.js.map +1 -1
- package/dist/index.cjs +373 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +373 -123
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +374 -124
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +374 -124
- package/dist/react.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/vue.cjs +374 -124
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.d.cts +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +374 -124
- package/dist/vue.js.map +1 -1
- package/package.json +1 -1
package/dist/angular.cjs
CHANGED
|
@@ -1679,19 +1679,85 @@ var FilePreviewViewer = class _FilePreviewViewer {
|
|
|
1679
1679
|
if (this.wrapperEl?.parentNode) {
|
|
1680
1680
|
this.wrapperEl.parentNode.removeChild(this.wrapperEl);
|
|
1681
1681
|
}
|
|
1682
|
+
if (typeof document !== "undefined" && !document.getElementById("fp-core-injected-styles")) {
|
|
1683
|
+
const styleEl = document.createElement("style");
|
|
1684
|
+
styleEl.id = "fp-core-injected-styles";
|
|
1685
|
+
styleEl.textContent = `
|
|
1686
|
+
.fp-viewer {
|
|
1687
|
+
display: flex !important;
|
|
1688
|
+
flex-direction: column !important;
|
|
1689
|
+
width: 100% !important;
|
|
1690
|
+
height: 100% !important;
|
|
1691
|
+
overflow: hidden !important;
|
|
1692
|
+
position: relative !important;
|
|
1693
|
+
box-sizing: border-box !important;
|
|
1694
|
+
}
|
|
1695
|
+
.fp-body {
|
|
1696
|
+
display: flex !important;
|
|
1697
|
+
flex: 1 1 0% !important;
|
|
1698
|
+
min-height: 0 !important;
|
|
1699
|
+
min-width: 0 !important;
|
|
1700
|
+
width: 100% !important;
|
|
1701
|
+
height: 100% !important;
|
|
1702
|
+
overflow: hidden !important;
|
|
1703
|
+
position: relative !important;
|
|
1704
|
+
box-sizing: border-box !important;
|
|
1705
|
+
}
|
|
1706
|
+
.fp-content {
|
|
1707
|
+
flex: 1 1 0% !important;
|
|
1708
|
+
position: relative !important;
|
|
1709
|
+
overflow: auto !important;
|
|
1710
|
+
display: flex !important;
|
|
1711
|
+
flex-direction: column !important;
|
|
1712
|
+
align-items: stretch !important;
|
|
1713
|
+
justify-content: flex-start !important;
|
|
1714
|
+
width: 100% !important;
|
|
1715
|
+
height: 100% !important;
|
|
1716
|
+
min-width: 0 !important;
|
|
1717
|
+
min-height: 0 !important;
|
|
1718
|
+
box-sizing: border-box !important;
|
|
1719
|
+
}
|
|
1720
|
+
`;
|
|
1721
|
+
document.head.appendChild(styleEl);
|
|
1722
|
+
}
|
|
1682
1723
|
const themeClass = options.theme === "dark" ? "fp-theme-dark" : "";
|
|
1683
1724
|
const toolbarPos = options.toolbarPosition ?? "top";
|
|
1684
1725
|
this.wrapperEl = document.createElement("div");
|
|
1685
1726
|
this.wrapperEl.className = `fp-viewer ${themeClass} ${options.className ?? ""}`.trim();
|
|
1686
1727
|
this.wrapperEl.tabIndex = 0;
|
|
1728
|
+
this.wrapperEl.style.display = "flex";
|
|
1729
|
+
this.wrapperEl.style.flexDirection = "column";
|
|
1730
|
+
this.wrapperEl.style.width = "100%";
|
|
1731
|
+
this.wrapperEl.style.height = "100%";
|
|
1732
|
+
this.wrapperEl.style.overflow = "hidden";
|
|
1733
|
+
this.wrapperEl.style.position = "relative";
|
|
1687
1734
|
const toolbarEl = document.createElement("div");
|
|
1688
1735
|
toolbarEl.className = "fp-toolbar-container";
|
|
1689
1736
|
this.contentEl = document.createElement("div");
|
|
1690
1737
|
this.contentEl.className = "fp-content";
|
|
1738
|
+
this.contentEl.style.flex = "1 1 0%";
|
|
1739
|
+
this.contentEl.style.position = "relative";
|
|
1740
|
+
this.contentEl.style.overflow = "auto";
|
|
1741
|
+
this.contentEl.style.display = "flex";
|
|
1742
|
+
this.contentEl.style.flexDirection = "column";
|
|
1743
|
+
this.contentEl.style.alignItems = "stretch";
|
|
1744
|
+
this.contentEl.style.justifyContent = "flex-start";
|
|
1745
|
+
this.contentEl.style.width = "100%";
|
|
1746
|
+
this.contentEl.style.height = "100%";
|
|
1747
|
+
this.contentEl.style.minWidth = "0";
|
|
1748
|
+
this.contentEl.style.minHeight = "0";
|
|
1749
|
+
this.contentEl.style.boxSizing = "border-box";
|
|
1691
1750
|
const thumbnailEl = document.createElement("div");
|
|
1692
1751
|
thumbnailEl.className = "fp-thumbnail-container";
|
|
1693
1752
|
const bodyEl = document.createElement("div");
|
|
1694
1753
|
bodyEl.className = "fp-body";
|
|
1754
|
+
bodyEl.style.display = "flex";
|
|
1755
|
+
bodyEl.style.flex = "1 1 0%";
|
|
1756
|
+
bodyEl.style.minHeight = "0";
|
|
1757
|
+
bodyEl.style.minWidth = "0";
|
|
1758
|
+
bodyEl.style.width = "100%";
|
|
1759
|
+
bodyEl.style.overflow = "hidden";
|
|
1760
|
+
bodyEl.style.position = "relative";
|
|
1695
1761
|
bodyEl.appendChild(thumbnailEl);
|
|
1696
1762
|
bodyEl.appendChild(this.contentEl);
|
|
1697
1763
|
const titleBarEl = document.createElement("div");
|
|
@@ -4485,31 +4551,80 @@ function csvPlugin() {
|
|
|
4485
4551
|
}
|
|
4486
4552
|
var CODE_EXTENSIONS = [
|
|
4487
4553
|
".txt",
|
|
4554
|
+
".log",
|
|
4555
|
+
".ini",
|
|
4556
|
+
".cfg",
|
|
4557
|
+
".conf",
|
|
4558
|
+
".env",
|
|
4488
4559
|
".json",
|
|
4560
|
+
".jsonc",
|
|
4561
|
+
".json5",
|
|
4489
4562
|
".js",
|
|
4490
|
-
".
|
|
4563
|
+
".mjs",
|
|
4564
|
+
".cjs",
|
|
4491
4565
|
".jsx",
|
|
4566
|
+
".ts",
|
|
4567
|
+
".mts",
|
|
4568
|
+
".cts",
|
|
4492
4569
|
".tsx",
|
|
4493
4570
|
".html",
|
|
4571
|
+
".htm",
|
|
4572
|
+
".xhtml",
|
|
4494
4573
|
".css",
|
|
4495
4574
|
".scss",
|
|
4575
|
+
".sass",
|
|
4496
4576
|
".less",
|
|
4497
4577
|
".md",
|
|
4578
|
+
".markdown",
|
|
4498
4579
|
".xml",
|
|
4580
|
+
".svg",
|
|
4581
|
+
".xaml",
|
|
4499
4582
|
".yml",
|
|
4500
4583
|
".yaml",
|
|
4584
|
+
".toml",
|
|
4501
4585
|
".sh",
|
|
4502
4586
|
".bash",
|
|
4587
|
+
".zsh",
|
|
4588
|
+
".fish",
|
|
4589
|
+
".bat",
|
|
4590
|
+
".cmd",
|
|
4591
|
+
".ps1",
|
|
4503
4592
|
".py",
|
|
4593
|
+
".pyw",
|
|
4504
4594
|
".java",
|
|
4595
|
+
".class",
|
|
4505
4596
|
".c",
|
|
4506
4597
|
".cpp",
|
|
4598
|
+
".cc",
|
|
4599
|
+
".cxx",
|
|
4507
4600
|
".h",
|
|
4601
|
+
".hpp",
|
|
4602
|
+
".hxx",
|
|
4508
4603
|
".cs",
|
|
4604
|
+
".csx",
|
|
4509
4605
|
".go",
|
|
4510
4606
|
".rs",
|
|
4511
4607
|
".sql",
|
|
4512
|
-
".php"
|
|
4608
|
+
".php",
|
|
4609
|
+
".phtml",
|
|
4610
|
+
".rb",
|
|
4611
|
+
".swift",
|
|
4612
|
+
".kt",
|
|
4613
|
+
".kts",
|
|
4614
|
+
".scala",
|
|
4615
|
+
".r",
|
|
4616
|
+
".lua",
|
|
4617
|
+
".pl",
|
|
4618
|
+
".pm",
|
|
4619
|
+
".dart",
|
|
4620
|
+
".graphql",
|
|
4621
|
+
".gql",
|
|
4622
|
+
".proto",
|
|
4623
|
+
".diff",
|
|
4624
|
+
".patch",
|
|
4625
|
+
".dockerfile",
|
|
4626
|
+
".properties",
|
|
4627
|
+
".gradle"
|
|
4513
4628
|
];
|
|
4514
4629
|
var CodePlugin = class {
|
|
4515
4630
|
id = "code";
|
|
@@ -4527,34 +4642,36 @@ var CodePlugin = class {
|
|
|
4527
4642
|
getToolbarActions(instance) {
|
|
4528
4643
|
const totalPages = instance.getPageCount?.() ?? 1;
|
|
4529
4644
|
const actions = [];
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
if (
|
|
4551
|
-
|
|
4552
|
-
if (
|
|
4553
|
-
|
|
4554
|
-
|
|
4645
|
+
if (totalPages > 1) {
|
|
4646
|
+
actions.push({
|
|
4647
|
+
id: "thumbnails",
|
|
4648
|
+
icon: "thumbnails",
|
|
4649
|
+
label: "Page Thumbnails",
|
|
4650
|
+
type: "button",
|
|
4651
|
+
group: "navigation",
|
|
4652
|
+
execute: () => instance.toggleThumbnails?.()
|
|
4653
|
+
});
|
|
4654
|
+
actions.push({
|
|
4655
|
+
id: "page-nav",
|
|
4656
|
+
icon: "",
|
|
4657
|
+
label: "Page Navigation",
|
|
4658
|
+
type: "page-nav",
|
|
4659
|
+
group: "navigation",
|
|
4660
|
+
value: instance.getCurrentPage?.() ?? 1,
|
|
4661
|
+
max: totalPages,
|
|
4662
|
+
execute: (action, page) => {
|
|
4663
|
+
const cur = instance.getCurrentPage?.() ?? 1;
|
|
4664
|
+
const max = instance.getPageCount?.() ?? 1;
|
|
4665
|
+
if (action === "prev") {
|
|
4666
|
+
if (cur > 1) instance.goToPage?.(cur - 1);
|
|
4667
|
+
} else if (action === "next") {
|
|
4668
|
+
if (cur < max) instance.goToPage?.(cur + 1);
|
|
4669
|
+
} else if (typeof page === "number") {
|
|
4670
|
+
instance.goToPage?.(page);
|
|
4671
|
+
}
|
|
4555
4672
|
}
|
|
4556
|
-
}
|
|
4557
|
-
}
|
|
4673
|
+
});
|
|
4674
|
+
}
|
|
4558
4675
|
actions.push(
|
|
4559
4676
|
{
|
|
4560
4677
|
id: "zoom-out",
|
|
@@ -4691,10 +4808,6 @@ var CodePlugin = class {
|
|
|
4691
4808
|
}
|
|
4692
4809
|
const totalPages = Math.max(1, rawPages.length);
|
|
4693
4810
|
let currentPage = 1;
|
|
4694
|
-
const container = document.createElement("div");
|
|
4695
|
-
container.style.width = "100%";
|
|
4696
|
-
container.style.height = "100%";
|
|
4697
|
-
container.style.overflow = "auto";
|
|
4698
4811
|
let fontSize = 13;
|
|
4699
4812
|
let rotation = 0;
|
|
4700
4813
|
let zoomLevel = 1;
|
|
@@ -4703,9 +4816,10 @@ var CodePlugin = class {
|
|
|
4703
4816
|
const code = document.createElement("code");
|
|
4704
4817
|
const sizer = document.createElement("div");
|
|
4705
4818
|
const scrollWrapper = document.createElement("div");
|
|
4819
|
+
const lineGutter = document.createElement("div");
|
|
4820
|
+
ctx.container.style.overflow = "auto";
|
|
4706
4821
|
if (isTxt) {
|
|
4707
|
-
container.style.
|
|
4708
|
-
container.style.backgroundColor = "#f1f5f9";
|
|
4822
|
+
ctx.container.style.backgroundColor = "#f1f5f9";
|
|
4709
4823
|
scrollWrapper.className = "fp-code-scroll-wrapper";
|
|
4710
4824
|
scrollWrapper.style.minWidth = "100%";
|
|
4711
4825
|
scrollWrapper.style.minHeight = "100%";
|
|
@@ -4740,18 +4854,42 @@ var CodePlugin = class {
|
|
|
4740
4854
|
pre.style.transition = "transform 0.15s ease";
|
|
4741
4855
|
pre.style.flexShrink = "0";
|
|
4742
4856
|
} else {
|
|
4743
|
-
container.style.
|
|
4744
|
-
container.style.
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4857
|
+
ctx.container.style.backgroundColor = "#1e1e1e";
|
|
4858
|
+
ctx.container.style.color = "#d4d4d4";
|
|
4859
|
+
scrollWrapper.className = "fp-code-scroll-wrapper";
|
|
4860
|
+
scrollWrapper.style.minWidth = "100%";
|
|
4861
|
+
scrollWrapper.style.minHeight = "100%";
|
|
4862
|
+
scrollWrapper.style.width = "max-content";
|
|
4863
|
+
scrollWrapper.style.height = "max-content";
|
|
4864
|
+
scrollWrapper.style.display = "flex";
|
|
4865
|
+
scrollWrapper.style.alignItems = "flex-start";
|
|
4866
|
+
scrollWrapper.style.padding = "16px";
|
|
4867
|
+
scrollWrapper.style.boxSizing = "border-box";
|
|
4868
|
+
const lineCount = fullText.split(/\r?\n/).length || 1;
|
|
4869
|
+
const gutterLines = [];
|
|
4870
|
+
for (let i = 1; i <= lineCount; i++) {
|
|
4871
|
+
gutterLines.push(String(i));
|
|
4872
|
+
}
|
|
4873
|
+
lineGutter.className = "fp-code-gutter";
|
|
4874
|
+
lineGutter.style.userSelect = "none";
|
|
4875
|
+
lineGutter.style.textAlign = "right";
|
|
4876
|
+
lineGutter.style.paddingRight = "16px";
|
|
4877
|
+
lineGutter.style.marginRight = "16px";
|
|
4878
|
+
lineGutter.style.borderRight = "1px solid #333333";
|
|
4879
|
+
lineGutter.style.color = "#858585";
|
|
4880
|
+
lineGutter.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
|
|
4881
|
+
lineGutter.style.fontSize = `${fontSize}px`;
|
|
4882
|
+
lineGutter.style.lineHeight = "1.6";
|
|
4883
|
+
lineGutter.style.flexShrink = "0";
|
|
4884
|
+
lineGutter.textContent = gutterLines.join("\n");
|
|
4748
4885
|
pre.style.margin = "0";
|
|
4749
|
-
pre.style.fontFamily = "Consolas, Menlo, Monaco, monospace";
|
|
4886
|
+
pre.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
|
|
4750
4887
|
pre.style.fontSize = `${fontSize}px`;
|
|
4751
|
-
pre.style.lineHeight = "1.
|
|
4752
|
-
pre.style.whiteSpace = "pre
|
|
4753
|
-
pre.style.wordBreak = "
|
|
4754
|
-
pre.style.
|
|
4888
|
+
pre.style.lineHeight = "1.6";
|
|
4889
|
+
pre.style.whiteSpace = "pre";
|
|
4890
|
+
pre.style.wordBreak = "normal";
|
|
4891
|
+
pre.style.overflowWrap = "normal";
|
|
4892
|
+
pre.style.flex = "1";
|
|
4755
4893
|
}
|
|
4756
4894
|
const ext = (ctx.metadata.extension || "").replace(".", "");
|
|
4757
4895
|
const renderCodePage = (text) => {
|
|
@@ -4771,25 +4909,27 @@ var CodePlugin = class {
|
|
|
4771
4909
|
};
|
|
4772
4910
|
renderCodePage(rawPages[0] || (isTxt ? "" : fullText));
|
|
4773
4911
|
pre.appendChild(code);
|
|
4912
|
+
ctx.container.innerHTML = "";
|
|
4774
4913
|
if (isTxt) {
|
|
4775
4914
|
sizer.appendChild(pre);
|
|
4776
4915
|
scrollWrapper.appendChild(sizer);
|
|
4777
|
-
container.appendChild(scrollWrapper);
|
|
4916
|
+
ctx.container.appendChild(scrollWrapper);
|
|
4778
4917
|
} else {
|
|
4779
|
-
|
|
4918
|
+
scrollWrapper.appendChild(lineGutter);
|
|
4919
|
+
scrollWrapper.appendChild(pre);
|
|
4920
|
+
ctx.container.appendChild(scrollWrapper);
|
|
4780
4921
|
}
|
|
4781
4922
|
const showPage = (pageNum) => {
|
|
4782
4923
|
currentPage = Math.max(1, Math.min(totalPages, pageNum));
|
|
4783
4924
|
renderCodePage(rawPages[currentPage - 1] || (isTxt ? "" : fullText));
|
|
4784
|
-
container.scrollTop = 0;
|
|
4925
|
+
ctx.container.scrollTop = 0;
|
|
4785
4926
|
ctx.emit("page-change", { page: currentPage, total: totalPages });
|
|
4786
4927
|
};
|
|
4787
4928
|
if (totalPages > 1) {
|
|
4788
4929
|
showPage(1);
|
|
4789
4930
|
}
|
|
4790
|
-
ctx.container.appendChild(container);
|
|
4791
4931
|
const calculateTxtFit = () => {
|
|
4792
|
-
const availW = Math.max(280, container.clientWidth - 32);
|
|
4932
|
+
const availW = Math.max(280, ctx.container.clientWidth - 32);
|
|
4793
4933
|
return Math.max(0.4, Math.min(3, availW / 816));
|
|
4794
4934
|
};
|
|
4795
4935
|
const updateTransform = () => {
|
|
@@ -4807,6 +4947,7 @@ var CodePlugin = class {
|
|
|
4807
4947
|
} else {
|
|
4808
4948
|
pre.style.transform = `rotate(${rotation}deg)`;
|
|
4809
4949
|
pre.style.fontSize = `${fontSize}px`;
|
|
4950
|
+
lineGutter.style.fontSize = `${fontSize}px`;
|
|
4810
4951
|
}
|
|
4811
4952
|
};
|
|
4812
4953
|
let resizeObserver = null;
|
|
@@ -4821,11 +4962,11 @@ var CodePlugin = class {
|
|
|
4821
4962
|
updateTransform();
|
|
4822
4963
|
}
|
|
4823
4964
|
}) : null;
|
|
4824
|
-
resizeObserver?.observe(container);
|
|
4965
|
+
resizeObserver?.observe(ctx.container);
|
|
4825
4966
|
}
|
|
4826
4967
|
const cleanup = () => {
|
|
4827
4968
|
resizeObserver?.disconnect();
|
|
4828
|
-
|
|
4969
|
+
scrollWrapper.remove();
|
|
4829
4970
|
ctx.container.innerHTML = "";
|
|
4830
4971
|
};
|
|
4831
4972
|
ctx.signal.addEventListener("abort", cleanup);
|
|
@@ -4870,7 +5011,7 @@ var CodePlugin = class {
|
|
|
4870
5011
|
if (isTxt) {
|
|
4871
5012
|
zoomLevel = Math.min(3.5, zoomLevel + 0.15);
|
|
4872
5013
|
} else {
|
|
4873
|
-
fontSize = Math.min(
|
|
5014
|
+
fontSize = Math.min(48, fontSize + 2);
|
|
4874
5015
|
}
|
|
4875
5016
|
updateTransform();
|
|
4876
5017
|
},
|
|
@@ -4879,7 +5020,7 @@ var CodePlugin = class {
|
|
|
4879
5020
|
if (isTxt) {
|
|
4880
5021
|
zoomLevel = Math.max(0.1, zoomLevel - 0.15);
|
|
4881
5022
|
} else {
|
|
4882
|
-
fontSize = Math.max(
|
|
5023
|
+
fontSize = Math.max(9, fontSize - 2);
|
|
4883
5024
|
}
|
|
4884
5025
|
updateTransform();
|
|
4885
5026
|
},
|
|
@@ -4912,8 +5053,8 @@ var CodePlugin = class {
|
|
|
4912
5053
|
fontSize = 13;
|
|
4913
5054
|
rotation = 0;
|
|
4914
5055
|
zoomLevel = isTxt ? calculateTxtFit() : 1;
|
|
4915
|
-
container.scrollTop = 0;
|
|
4916
|
-
container.scrollLeft = 0;
|
|
5056
|
+
ctx.container.scrollTop = 0;
|
|
5057
|
+
ctx.container.scrollLeft = 0;
|
|
4917
5058
|
updateTransform();
|
|
4918
5059
|
},
|
|
4919
5060
|
rotateCW: () => {
|
|
@@ -5235,7 +5376,7 @@ var MarkdownPlugin = class {
|
|
|
5235
5376
|
{
|
|
5236
5377
|
id: "zoom-out",
|
|
5237
5378
|
icon: "zoom-out",
|
|
5238
|
-
label: "
|
|
5379
|
+
label: "Zoom Out",
|
|
5239
5380
|
type: "button",
|
|
5240
5381
|
group: "zoom",
|
|
5241
5382
|
execute: () => instance.zoomOut?.()
|
|
@@ -5243,19 +5384,11 @@ var MarkdownPlugin = class {
|
|
|
5243
5384
|
{
|
|
5244
5385
|
id: "zoom-in",
|
|
5245
5386
|
icon: "zoom-in",
|
|
5246
|
-
label: "
|
|
5387
|
+
label: "Zoom In",
|
|
5247
5388
|
type: "button",
|
|
5248
5389
|
group: "zoom",
|
|
5249
5390
|
execute: () => instance.zoomIn?.()
|
|
5250
5391
|
},
|
|
5251
|
-
{
|
|
5252
|
-
id: "fit-page",
|
|
5253
|
-
icon: "fit-page",
|
|
5254
|
-
label: "Default Size",
|
|
5255
|
-
type: "button",
|
|
5256
|
-
group: "zoom",
|
|
5257
|
-
execute: () => instance.fitToPage?.()
|
|
5258
|
-
},
|
|
5259
5392
|
{
|
|
5260
5393
|
id: "reset-zoom",
|
|
5261
5394
|
icon: "reset-zoom",
|
|
@@ -5272,6 +5405,14 @@ var MarkdownPlugin = class {
|
|
|
5272
5405
|
group: "zoom",
|
|
5273
5406
|
execute: () => instance.fitToWidth?.()
|
|
5274
5407
|
},
|
|
5408
|
+
{
|
|
5409
|
+
id: "fit-page",
|
|
5410
|
+
icon: "fit-page",
|
|
5411
|
+
label: "Fit to Page",
|
|
5412
|
+
type: "button",
|
|
5413
|
+
group: "zoom",
|
|
5414
|
+
execute: () => instance.fitToPage?.()
|
|
5415
|
+
},
|
|
5275
5416
|
{
|
|
5276
5417
|
id: "copy",
|
|
5277
5418
|
icon: "copy",
|
|
@@ -5295,6 +5436,14 @@ var MarkdownPlugin = class {
|
|
|
5295
5436
|
type: "button",
|
|
5296
5437
|
group: "actions",
|
|
5297
5438
|
execute: () => instance.print?.()
|
|
5439
|
+
},
|
|
5440
|
+
{
|
|
5441
|
+
id: "open-window",
|
|
5442
|
+
icon: "open-window",
|
|
5443
|
+
label: "Open in Separate Full Window",
|
|
5444
|
+
type: "button",
|
|
5445
|
+
group: "actions",
|
|
5446
|
+
execute: () => instance.openInSeparateWindow?.()
|
|
5298
5447
|
}
|
|
5299
5448
|
];
|
|
5300
5449
|
}
|
|
@@ -5307,35 +5456,57 @@ var MarkdownPlugin = class {
|
|
|
5307
5456
|
const cleanHtml = DOMPurify6__default.default.sanitize(rawHtml, {
|
|
5308
5457
|
USE_PROFILES: { html: true }
|
|
5309
5458
|
});
|
|
5310
|
-
const
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5459
|
+
const scrollWrapper = document.createElement("div");
|
|
5460
|
+
scrollWrapper.className = "fp-markdown-scroll-wrapper";
|
|
5461
|
+
scrollWrapper.style.minWidth = "100%";
|
|
5462
|
+
scrollWrapper.style.minHeight = "100%";
|
|
5463
|
+
scrollWrapper.style.width = "max-content";
|
|
5464
|
+
scrollWrapper.style.height = "max-content";
|
|
5465
|
+
scrollWrapper.style.display = "flex";
|
|
5466
|
+
scrollWrapper.style.justifyContent = "center";
|
|
5467
|
+
scrollWrapper.style.alignItems = "flex-start";
|
|
5468
|
+
scrollWrapper.style.padding = "24px 16px";
|
|
5469
|
+
scrollWrapper.style.boxSizing = "border-box";
|
|
5470
|
+
const sizer = document.createElement("div");
|
|
5471
|
+
sizer.className = "fp-markdown-sizer";
|
|
5472
|
+
sizer.style.position = "relative";
|
|
5473
|
+
sizer.style.flexShrink = "0";
|
|
5474
|
+
sizer.style.display = "flex";
|
|
5475
|
+
sizer.style.justifyContent = "center";
|
|
5476
|
+
sizer.style.alignItems = "flex-start";
|
|
5477
|
+
const docCard = document.createElement("div");
|
|
5478
|
+
docCard.className = "fp-markdown-doc-card";
|
|
5479
|
+
docCard.style.cssText = `
|
|
5480
|
+
width: 860px;
|
|
5481
|
+
min-height: 600px;
|
|
5482
|
+
padding: 40px 48px;
|
|
5317
5483
|
box-sizing: border-box;
|
|
5318
5484
|
line-height: 1.6;
|
|
5319
5485
|
font-size: 15px;
|
|
5320
5486
|
color: var(--fp-text, #24292f);
|
|
5321
5487
|
background: var(--fp-bg, #ffffff);
|
|
5488
|
+
border-radius: 6px;
|
|
5489
|
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
|
|
5322
5490
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
|
|
5491
|
+
transform-origin: top center;
|
|
5492
|
+
transition: transform 0.15s ease;
|
|
5493
|
+
flex-shrink: 0;
|
|
5323
5494
|
`;
|
|
5324
|
-
|
|
5495
|
+
docCard.innerHTML = `
|
|
5325
5496
|
<style>
|
|
5326
|
-
.fp-markdown-
|
|
5327
|
-
.fp-markdown-
|
|
5497
|
+
.fp-markdown-doc-card h1, .fp-markdown-doc-card h2, .fp-markdown-doc-card h3,
|
|
5498
|
+
.fp-markdown-doc-card h4, .fp-markdown-doc-card h5, .fp-markdown-doc-card h6 {
|
|
5328
5499
|
margin-top: 24px;
|
|
5329
5500
|
margin-bottom: 16px;
|
|
5330
5501
|
font-weight: 600;
|
|
5331
5502
|
line-height: 1.25;
|
|
5332
5503
|
color: var(--fp-text, #1f2328);
|
|
5333
5504
|
}
|
|
5334
|
-
.fp-markdown-
|
|
5335
|
-
.fp-markdown-
|
|
5336
|
-
.fp-markdown-
|
|
5337
|
-
.fp-markdown-
|
|
5338
|
-
.fp-markdown-
|
|
5505
|
+
.fp-markdown-doc-card h1 { font-size: 2em; padding-bottom: 0.3em; border-bottom: 1px solid var(--fp-border, #d0d7de); }
|
|
5506
|
+
.fp-markdown-doc-card h2 { font-size: 1.5em; padding-bottom: 0.3em; border-bottom: 1px solid var(--fp-border, #d0d7de); }
|
|
5507
|
+
.fp-markdown-doc-card h3 { font-size: 1.25em; }
|
|
5508
|
+
.fp-markdown-doc-card p { margin-top: 0; margin-bottom: 16px; }
|
|
5509
|
+
.fp-markdown-doc-card table {
|
|
5339
5510
|
border-spacing: 0;
|
|
5340
5511
|
border-collapse: collapse;
|
|
5341
5512
|
margin-top: 0;
|
|
@@ -5343,20 +5514,20 @@ var MarkdownPlugin = class {
|
|
|
5343
5514
|
width: 100%;
|
|
5344
5515
|
overflow: auto;
|
|
5345
5516
|
}
|
|
5346
|
-
.fp-markdown-
|
|
5517
|
+
.fp-markdown-doc-card table th, .fp-markdown-doc-card table td {
|
|
5347
5518
|
padding: 6px 13px;
|
|
5348
5519
|
border: 1px solid var(--fp-border, #d0d7de);
|
|
5349
5520
|
}
|
|
5350
|
-
.fp-markdown-
|
|
5521
|
+
.fp-markdown-doc-card table tr:nth-child(2n) {
|
|
5351
5522
|
background-color: var(--fp-toolbar-bg, #f6f8fa);
|
|
5352
5523
|
}
|
|
5353
|
-
.fp-markdown-
|
|
5524
|
+
.fp-markdown-doc-card blockquote {
|
|
5354
5525
|
margin: 0 0 16px 0;
|
|
5355
5526
|
padding: 0 1em;
|
|
5356
5527
|
color: var(--fp-text-muted, #59636e);
|
|
5357
5528
|
border-left: 0.25em solid var(--fp-border, #d0d7de);
|
|
5358
5529
|
}
|
|
5359
|
-
.fp-markdown-
|
|
5530
|
+
.fp-markdown-doc-card pre {
|
|
5360
5531
|
padding: 16px;
|
|
5361
5532
|
overflow: auto;
|
|
5362
5533
|
font-size: 85%;
|
|
@@ -5365,7 +5536,7 @@ var MarkdownPlugin = class {
|
|
|
5365
5536
|
border-radius: 6px;
|
|
5366
5537
|
border: 1px solid var(--fp-border, #d0d7de);
|
|
5367
5538
|
}
|
|
5368
|
-
.fp-markdown-
|
|
5539
|
+
.fp-markdown-doc-card code {
|
|
5369
5540
|
padding: 0.2em 0.4em;
|
|
5370
5541
|
margin: 0;
|
|
5371
5542
|
font-size: 85%;
|
|
@@ -5373,16 +5544,16 @@ var MarkdownPlugin = class {
|
|
|
5373
5544
|
border-radius: 4px;
|
|
5374
5545
|
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
|
|
5375
5546
|
}
|
|
5376
|
-
.fp-markdown-
|
|
5547
|
+
.fp-markdown-doc-card pre code {
|
|
5377
5548
|
padding: 0;
|
|
5378
5549
|
background: transparent;
|
|
5379
5550
|
}
|
|
5380
|
-
.fp-markdown-
|
|
5551
|
+
.fp-markdown-doc-card ul, .fp-markdown-doc-card ol {
|
|
5381
5552
|
padding-left: 2em;
|
|
5382
5553
|
margin-top: 0;
|
|
5383
5554
|
margin-bottom: 16px;
|
|
5384
5555
|
}
|
|
5385
|
-
.fp-markdown-
|
|
5556
|
+
.fp-markdown-doc-card hr {
|
|
5386
5557
|
height: 0.25em;
|
|
5387
5558
|
padding: 0;
|
|
5388
5559
|
margin: 24px 0;
|
|
@@ -5390,50 +5561,95 @@ var MarkdownPlugin = class {
|
|
|
5390
5561
|
border: 0;
|
|
5391
5562
|
}
|
|
5392
5563
|
</style>
|
|
5393
|
-
<div class="fp-markdown-
|
|
5564
|
+
<div class="fp-markdown-body">
|
|
5394
5565
|
${cleanHtml}
|
|
5395
5566
|
</div>
|
|
5396
5567
|
`;
|
|
5397
|
-
|
|
5568
|
+
docCard.querySelectorAll("pre code").forEach((block) => {
|
|
5398
5569
|
hljs__default.default.highlightElement(block);
|
|
5399
5570
|
});
|
|
5571
|
+
sizer.appendChild(docCard);
|
|
5572
|
+
scrollWrapper.appendChild(sizer);
|
|
5400
5573
|
ctx.container.innerHTML = "";
|
|
5401
5574
|
ctx.container.style.overflow = "auto";
|
|
5402
|
-
ctx.container.
|
|
5403
|
-
|
|
5575
|
+
ctx.container.style.backgroundColor = "#f1f5f9";
|
|
5576
|
+
ctx.container.appendChild(scrollWrapper);
|
|
5577
|
+
let scale = 1;
|
|
5578
|
+
let isUserZoomed = false;
|
|
5579
|
+
const calculateFitScale = () => {
|
|
5580
|
+
const availW = Math.max(280, ctx.container.clientWidth - 48);
|
|
5581
|
+
if (availW < 860) {
|
|
5582
|
+
return Math.max(0.35, availW / 860);
|
|
5583
|
+
}
|
|
5584
|
+
return 1;
|
|
5585
|
+
};
|
|
5586
|
+
const applyTransform = () => {
|
|
5587
|
+
const baseW = 860;
|
|
5588
|
+
const baseH = docCard.offsetHeight || 600;
|
|
5589
|
+
const scaledW = Math.round(baseW * scale);
|
|
5590
|
+
const scaledH = Math.round(baseH * scale);
|
|
5591
|
+
sizer.style.width = `${scaledW}px`;
|
|
5592
|
+
sizer.style.height = `${scaledH}px`;
|
|
5593
|
+
docCard.style.width = `${baseW}px`;
|
|
5594
|
+
docCard.style.transform = `scale(${scale})`;
|
|
5595
|
+
docCard.style.transformOrigin = scaledW > ctx.container.clientWidth - 32 ? "top left" : "top center";
|
|
5596
|
+
};
|
|
5597
|
+
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
|
|
5598
|
+
if (!isUserZoomed) {
|
|
5599
|
+
scale = calculateFitScale();
|
|
5600
|
+
applyTransform();
|
|
5601
|
+
}
|
|
5602
|
+
}) : null;
|
|
5603
|
+
ro?.observe(ctx.container);
|
|
5604
|
+
requestAnimationFrame(() => {
|
|
5605
|
+
if (!isUserZoomed) {
|
|
5606
|
+
scale = calculateFitScale();
|
|
5607
|
+
}
|
|
5608
|
+
applyTransform();
|
|
5609
|
+
});
|
|
5404
5610
|
const cleanup = () => {
|
|
5405
|
-
|
|
5611
|
+
ro?.disconnect();
|
|
5612
|
+
scrollWrapper.remove();
|
|
5406
5613
|
ctx.container.innerHTML = "";
|
|
5407
5614
|
};
|
|
5408
5615
|
ctx.signal.addEventListener("abort", cleanup);
|
|
5409
5616
|
return {
|
|
5410
5617
|
destroy: cleanup,
|
|
5411
5618
|
zoomIn: () => {
|
|
5412
|
-
|
|
5413
|
-
|
|
5619
|
+
isUserZoomed = true;
|
|
5620
|
+
scale = Math.min(3.5, scale + 0.15);
|
|
5621
|
+
applyTransform();
|
|
5414
5622
|
},
|
|
5415
5623
|
zoomOut: () => {
|
|
5416
|
-
|
|
5417
|
-
|
|
5624
|
+
isUserZoomed = true;
|
|
5625
|
+
scale = Math.max(0.25, scale - 0.15);
|
|
5626
|
+
applyTransform();
|
|
5418
5627
|
},
|
|
5419
|
-
getZoom: () =>
|
|
5628
|
+
getZoom: () => scale,
|
|
5420
5629
|
setZoom: (level) => {
|
|
5421
|
-
|
|
5422
|
-
|
|
5630
|
+
isUserZoomed = true;
|
|
5631
|
+
scale = level;
|
|
5632
|
+
applyTransform();
|
|
5423
5633
|
},
|
|
5424
5634
|
fitToPage: () => {
|
|
5425
|
-
|
|
5426
|
-
|
|
5635
|
+
isUserZoomed = false;
|
|
5636
|
+
scale = calculateFitScale();
|
|
5637
|
+
applyTransform();
|
|
5427
5638
|
},
|
|
5428
5639
|
fitToWidth: () => {
|
|
5429
|
-
|
|
5430
|
-
|
|
5640
|
+
isUserZoomed = false;
|
|
5641
|
+
scale = calculateFitScale();
|
|
5642
|
+
applyTransform();
|
|
5431
5643
|
},
|
|
5432
5644
|
resetZoom: () => {
|
|
5433
|
-
|
|
5434
|
-
|
|
5645
|
+
isUserZoomed = false;
|
|
5646
|
+
scale = calculateFitScale();
|
|
5435
5647
|
ctx.container.scrollTop = 0;
|
|
5436
5648
|
ctx.container.scrollLeft = 0;
|
|
5649
|
+
applyTransform();
|
|
5650
|
+
},
|
|
5651
|
+
openInSeparateWindow: () => {
|
|
5652
|
+
ctx?.openInSeparateWindow?.();
|
|
5437
5653
|
},
|
|
5438
5654
|
download: () => {
|
|
5439
5655
|
downloadFile(ctx.buffer, ctx.metadata.name || "document.md", "text/markdown");
|
|
@@ -6749,14 +6965,6 @@ var HtmlPreviewPlugin = class {
|
|
|
6749
6965
|
group: "zoom",
|
|
6750
6966
|
execute: () => instance.zoomIn?.()
|
|
6751
6967
|
},
|
|
6752
|
-
{
|
|
6753
|
-
id: "fit-page",
|
|
6754
|
-
icon: "fit-page",
|
|
6755
|
-
label: "Fit to Page",
|
|
6756
|
-
type: "button",
|
|
6757
|
-
group: "zoom",
|
|
6758
|
-
execute: () => instance.fitToPage?.()
|
|
6759
|
-
},
|
|
6760
6968
|
{
|
|
6761
6969
|
id: "reset-zoom",
|
|
6762
6970
|
icon: "reset-zoom",
|
|
@@ -6773,6 +6981,14 @@ var HtmlPreviewPlugin = class {
|
|
|
6773
6981
|
group: "zoom",
|
|
6774
6982
|
execute: () => instance.fitToWidth?.()
|
|
6775
6983
|
},
|
|
6984
|
+
{
|
|
6985
|
+
id: "fit-page",
|
|
6986
|
+
icon: "fit-page",
|
|
6987
|
+
label: "Fit to Page",
|
|
6988
|
+
type: "button",
|
|
6989
|
+
group: "zoom",
|
|
6990
|
+
execute: () => instance.fitToPage?.()
|
|
6991
|
+
},
|
|
6776
6992
|
{
|
|
6777
6993
|
id: "copy",
|
|
6778
6994
|
icon: "copy",
|
|
@@ -6796,6 +7012,14 @@ var HtmlPreviewPlugin = class {
|
|
|
6796
7012
|
type: "button",
|
|
6797
7013
|
group: "actions",
|
|
6798
7014
|
execute: () => instance.print?.()
|
|
7015
|
+
},
|
|
7016
|
+
{
|
|
7017
|
+
id: "open-window",
|
|
7018
|
+
icon: "open-window",
|
|
7019
|
+
label: "Open in Separate Full Window",
|
|
7020
|
+
type: "button",
|
|
7021
|
+
group: "actions",
|
|
7022
|
+
execute: () => instance.openInSeparateWindow?.()
|
|
6799
7023
|
}
|
|
6800
7024
|
];
|
|
6801
7025
|
}
|
|
@@ -6806,27 +7030,39 @@ var HtmlPreviewPlugin = class {
|
|
|
6806
7030
|
ADD_TAGS: ["style", "link"],
|
|
6807
7031
|
ADD_ATTR: ["target", "rel"]
|
|
6808
7032
|
});
|
|
7033
|
+
const scrollWrapper = document.createElement("div");
|
|
7034
|
+
scrollWrapper.className = "fp-html-scroll-wrapper";
|
|
7035
|
+
scrollWrapper.style.minWidth = "100%";
|
|
7036
|
+
scrollWrapper.style.minHeight = "100%";
|
|
7037
|
+
scrollWrapper.style.width = "max-content";
|
|
7038
|
+
scrollWrapper.style.height = "max-content";
|
|
7039
|
+
scrollWrapper.style.display = "flex";
|
|
7040
|
+
scrollWrapper.style.justifyContent = "flex-start";
|
|
7041
|
+
scrollWrapper.style.alignItems = "flex-start";
|
|
7042
|
+
scrollWrapper.style.boxSizing = "border-box";
|
|
6809
7043
|
const sizer = document.createElement("div");
|
|
6810
7044
|
sizer.className = "fp-html-sizer";
|
|
6811
7045
|
sizer.style.position = "relative";
|
|
7046
|
+
sizer.style.flexShrink = "0";
|
|
6812
7047
|
const iframe = document.createElement("iframe");
|
|
6813
7048
|
iframe.className = "fp-html-iframe";
|
|
6814
7049
|
iframe.style.border = "none";
|
|
6815
7050
|
iframe.style.backgroundColor = "#ffffff";
|
|
6816
7051
|
iframe.style.transformOrigin = "top left";
|
|
6817
|
-
iframe.style.transition = "transform 0.
|
|
7052
|
+
iframe.style.transition = "transform 0.15s ease";
|
|
6818
7053
|
iframe.sandbox.add("allow-same-origin");
|
|
6819
7054
|
sizer.appendChild(iframe);
|
|
7055
|
+
scrollWrapper.appendChild(sizer);
|
|
6820
7056
|
ctx.container.style.overflow = "auto";
|
|
6821
7057
|
ctx.container.style.width = "100%";
|
|
6822
7058
|
ctx.container.style.height = "100%";
|
|
6823
7059
|
ctx.container.innerHTML = "";
|
|
6824
|
-
ctx.container.appendChild(
|
|
7060
|
+
ctx.container.appendChild(scrollWrapper);
|
|
6825
7061
|
iframe.srcdoc = sanitized;
|
|
6826
7062
|
let scale = 1;
|
|
7063
|
+
let baseW = Math.max(600, ctx.container.clientWidth || 800);
|
|
7064
|
+
let baseH = Math.max(400, ctx.container.clientHeight || 600);
|
|
6827
7065
|
const applyTransform = () => {
|
|
6828
|
-
const baseW = Math.max(600, ctx.container.clientWidth || 800);
|
|
6829
|
-
const baseH = Math.max(400, ctx.container.clientHeight || 600);
|
|
6830
7066
|
const scaledW = Math.round(baseW * scale);
|
|
6831
7067
|
const scaledH = Math.round(baseH * scale);
|
|
6832
7068
|
sizer.style.width = `${scaledW}px`;
|
|
@@ -6839,22 +7075,33 @@ var HtmlPreviewPlugin = class {
|
|
|
6839
7075
|
iframe.style.transform = `scale(${scale})`;
|
|
6840
7076
|
iframe.style.transformOrigin = "top left";
|
|
6841
7077
|
};
|
|
7078
|
+
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
|
|
7079
|
+
if (Math.abs(scale - 1) < 0.05) {
|
|
7080
|
+
baseW = Math.max(600, ctx.container.clientWidth || 800);
|
|
7081
|
+
baseH = Math.max(400, ctx.container.clientHeight || 600);
|
|
7082
|
+
applyTransform();
|
|
7083
|
+
}
|
|
7084
|
+
}) : null;
|
|
7085
|
+
ro?.observe(ctx.container);
|
|
6842
7086
|
requestAnimationFrame(() => {
|
|
7087
|
+
baseW = Math.max(600, ctx.container.clientWidth || 800);
|
|
7088
|
+
baseH = Math.max(400, ctx.container.clientHeight || 600);
|
|
6843
7089
|
applyTransform();
|
|
6844
7090
|
});
|
|
6845
7091
|
const cleanup = () => {
|
|
6846
|
-
|
|
7092
|
+
ro?.disconnect();
|
|
7093
|
+
scrollWrapper.remove();
|
|
6847
7094
|
ctx.container.innerHTML = "";
|
|
6848
7095
|
};
|
|
6849
7096
|
ctx.signal.addEventListener("abort", cleanup);
|
|
6850
7097
|
return {
|
|
6851
7098
|
destroy: cleanup,
|
|
6852
7099
|
zoomIn: () => {
|
|
6853
|
-
scale
|
|
7100
|
+
scale = Math.min(3.5, scale + 0.15);
|
|
6854
7101
|
applyTransform();
|
|
6855
7102
|
},
|
|
6856
7103
|
zoomOut: () => {
|
|
6857
|
-
scale = Math.max(0.
|
|
7104
|
+
scale = Math.max(0.25, scale - 0.15);
|
|
6858
7105
|
applyTransform();
|
|
6859
7106
|
},
|
|
6860
7107
|
getZoom: () => scale,
|
|
@@ -6876,8 +7123,11 @@ var HtmlPreviewPlugin = class {
|
|
|
6876
7123
|
ctx.container.scrollLeft = 0;
|
|
6877
7124
|
applyTransform();
|
|
6878
7125
|
},
|
|
7126
|
+
openInSeparateWindow: () => {
|
|
7127
|
+
ctx?.openInSeparateWindow?.();
|
|
7128
|
+
},
|
|
6879
7129
|
copy: () => {
|
|
6880
|
-
navigator.clipboard
|
|
7130
|
+
navigator.clipboard?.writeText(rawHtml);
|
|
6881
7131
|
},
|
|
6882
7132
|
download: () => {
|
|
6883
7133
|
const blob = new Blob([ctx.buffer], { type: "text/html" });
|
|
@@ -8939,7 +9189,7 @@ _FilePreviewComponent_decorators = [core.Component({
|
|
|
8939
9189
|
selector: "fp-file-preview",
|
|
8940
9190
|
standalone: true,
|
|
8941
9191
|
imports: [common.CommonModule],
|
|
8942
|
-
template: `<div #container [style.width]="'100%'" [style.height]="'100%'"></div>`,
|
|
9192
|
+
template: `<div #container [style.width]="'100%'" [style.height]="'100%'" [style.position]="'relative'" [style.overflow]="'hidden'"></div>`,
|
|
8943
9193
|
changeDetection: core.ChangeDetectionStrategy.OnPush
|
|
8944
9194
|
})], _src_dec = [core.Input({ required: true })], _plugins_dec = [core.Input()], _options_dec = [core.Input()], _loading_dec = [core.Output()], _loaded_dec = [core.Output()], _error_dec = [core.Output()], _pageChange_dec = [core.Output()], _zoomChange_dec = [core.Output()], _rotate_dec = [core.Output()], _destroyed_dec = [core.Output()], _container_dec = [core.ViewChild("container", { static: true })];
|
|
8945
9195
|
exports.FilePreviewComponent = class FilePreviewComponent {
|